While I will post all of the code, I narrowed it down this line. This is one of those tricky errors that end up erroring out in some other file, and not telling you the origin (ie, the file category from the Error List window). Although, it does fail in the "type_traits" file.
std::pair<char*, T> thePair = std::make_pair(s, &createT<T>);
It will produce the following errors
Error 2 error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits 197
Error 3 error C2528: 'abstract declarator' : pointer to reference is illegal c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits 965
Error 4 error C2528: 'type' : pointer to reference is illegal c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits 349
Does anyone know why I am getting this error and how to prevent it?
#include <map>using std::map;class Component{protected: const char *m_ComponentName; Component(const char *componentName) : m_ComponentName(componentName) { }public: //Component() { } virtual ~Component() { }};template<typename T> Component * createT() { return new T; }struct BaseFactory { typedef std::map<char*, Component*(*)()> map_type; static Component * createInstance(char* s) { map_type::iterator it = getMap()->find(s); if(it == getMap()->end()) return 0; return it->second(); }protected: static map_type * getMap() { // never delete'ed. (exist until program termination) // because we can't guarantee correct destruction order if(!map) { map = new map_type; } return map; }private: static map_type * map;};template<typename T>struct DerivedRegister : BaseFactory { DerivedRegister(char* const& s) { std::pair<char*, T> thePair = std::make_pair(s, &createT<T>); getMap()->insert(thePair); }};class ComponentA : public Component{private: float A; static DerivedRegister<ComponentA> reg;public: ComponentA() : Component("ComponentA") { A = 0.0f; } ~ComponentA() { }};DerivedRegister<ComponentA> ComponentA::reg("ComponentA");class ComponentB : public Component{private: float B; static DerivedRegister<ComponentB> reg;public: ComponentB() : Component("ComponentB") { B = 0.0f; } ~ComponentB() { }};DerivedRegister<ComponentB> ComponentB::reg("ComponentB");int main(void){ BaseFactory theFacory; Component* testA = theFacory.createInstance("ComponentA"); return(0);}