Say I have a main DLL where there is a class like this:
class Test { public: typedef std::unordered_map< std::type_index, int > Map; template < typename T > void SetValue(int val) { SetValue(std::type_index(typeid(T)), val); } template < typename T > int GetValue() { return GetValue(std::type_index(typeid(T))); } protected: // Defined in .cpp file void SetValue(const std::type_index & idx, int val) { m_Map[idx] = val; } // Defined in .cpp file int GetValue(const std::type_index & idx) { Map::const_iterator itr = m_Map.find(idx); if (itr != m_Map.cend()) { return itr->second; } return 0; } private: Map m_Map; };
And I pass an instance of this class through several DLLs. And in one of the DLLs I set values like this:
template < typename T > struct Dummy { }; void InitFunc(Test * t) { t->SetValue< Dummy<int> >(32); t->SetValue< Dummy<char> >(10); t->SetValue< Dummy<float> >(27); }
And in another DLL I am trying to get these values using the same type Dummy. Am I getting the same values or 0?
Dummy
, ODR - . , 'Dummy' , --:). undefined, - , .
"" .
@SergeyA , std::type_info , , DLL .
std::type_info
std::type_info , , (, , ) , , .
, CppReference
type_index - std:: type_info, . type_info '
, DLL.
, std::type_index, , - , .
std::type_index
: ? , . , std ( STL) DLL.
, - :
, , , , .
Source: https://habr.com/ru/post/1618320/More articles:How to get a list of all available goals in Yocto? - linuxWhy does SBCL print Sublis like this? - lispHow to rename plugin title> Wordpress> Dashboard - wordpressThe complex tree structure forces the GC to pause indefinitely - closuresДействительно ли AVAudioUnitEQ работает на iOS? - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1618321/what-all-places-to-verify-file-upload-size-limit&usg=ALkJrhia-5x389wDPLFwxJ6Nk5nvbr7GrQIIS Express 8 - Maximum Allowed Length - c #Socket.io + node.js + express + ssl + Nginx - клиент не будет подключаться - 400 (неудачный запрос) - node.jsReact Native Navigator - the screen is always blank - javascriptHibernate 5, JPA 2.0 Web Web - springAll Articles