I'm having trouble with inserting some value_pairs into a map. Here's the basic idea.
// private
typedef Foo* (*Bar)( const std::string &x, int y );
typedef std::map<std::string, Bar> myMap;
template<class T>
Foo* DoThing( const std::string &x, int y ) {
return new T( x, y );
}
myMap m_map;
// some map insertion code
m_map.insert( myMap::value_type( "blah", &DoThing<SomeType> ));
m_map.insert( myMap::value_type( "blech", &DoThing<OtherType> ));
This would give a compiler error saying no matching function call to std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Foo* (*)(const std::string&, int)>::pair(const char [5], <unresolved overloaded function type>)
Not sure what I'm doing wrong syntactically, or why I'm getting the unresolved overloaded function type
. My best guess is that it doesn't know that DoThing
returns a Foo*
.
Any help appreciated, thanks.