Static map initialization function error

I get the following basic error:

1> c: \ program files \ microsoft visual studio 10.0 \ vc \ include \ utility (163): error C2436: 'second': member function or nested class in the list of constructor initializers

Like many subobjects, I have no idea where to look or what is going wrong. (I know what these functions are, but I look at myself blindly, why this does not work)

Title Part:

typedef void *DuplicateFn(pTree&, const pTree&); enum DuplicateTy { SKIP, OVERWRITE, ASK }; typedef std::map<DuplicateTy, DuplicateFn> DuplicateMapTy; static const DuplicateMapTy DuplicateFns; static DuplicateMapTy DuplicateFns_INIT(); 

verbose namespace:

 namespace detail { void OverWriteFn(GMProject::pTree& tOut, const GMProject::pTree& tIn); void AskFn(GMProject::pTree& tOut, const GMProject::pTree& tIn); } 

Source part:

 GMProject::DuplicateMapTy GMProject::DuplicateFns_INIT() { DuplicateMapTy tmp; auto p(std::make_pair(GMProject::OVERWRITE, &detail::OverWriteFn)); tmp.insert(p); //offending line return tmp; } const GMProject::DuplicateMapTy GMProject::DuplicateFns(GMProject::DuplicateFns_INIT()); 

Like I said, I look at myself blindly, why can't I insert this pair into the card? Am I just pasting a pointer to a function and an enumeration?

+1
source share
1 answer

Maybe I'm wrong, but I don't like the line:

 auto p(std::make_pair(GMProject::OVERWRITE, &detail::OverWriteFn)); 

Are you using VS 2010? You can type the variable name ( p ) and see what type of auto output.

In addition, you tried:

  tmp.insert(std::make_pair(GMProject::OVERWRITE, &detail::OverWriteFn)); 

Or

 tmp.insert(std::pair(GMProject::OVERWRITE, &detail::OverWriteFn)); 

?

0
source

Source: https://habr.com/ru/post/1382867/


All Articles