Tech Off Post

Single Post Permalink

View Thread: C++0x (vs2010) question, please tell me what i'm doing wrong
  • User profile image
    Dexter

    You're trying to assign a type name (default_delete<T>) to a variable (m_onLeaveScope_empty), you forgot a ():

    m_onLeaveScope_empty(default_empty<T>()) 

    It worked in the case of the func argument because you never use the default value in your tests. As soon as you write something like scoped<int, decltype(f)> f23(23); you'll get the same error. 

     

    Anyway, it still won't work. Once you fix this you'll get another error: '`anonymous-namespace'::<lambda1>::(const `anonymous-namespace'::<lambda1> &)' : cannot convert parameter 1 from 'default_empty<T>' to 'const `anonymous-namespace'::<lambda1> &'

     

    Again, you're mixing up things that look like functions but they have different types. In the particular case that triggered the above error your deleter is a lambda and the default_empty is a function object. They're not compatible.