, , " " factory [...]
RTTI ( , ; boost:: any ), ? .
#include <iostream>
#include <string>
using namespace std;
template <class T>
const char* my_type_id()
{
return "Unknown";
}
#define REGISTER_TYPE(some_type) \
template <> inline \
const char* my_type_id<some_type>() \
{ \
return #some_type; \
}
REGISTER_TYPE(int)
REGISTER_TYPE(std::string)
int main()
{
cout << my_type_id<int>() << endl;
cout << my_type_id<string>() << endl;
cout << my_type_id<char>() << endl;
}
, . , , , , ( "std::string", "", .).
boost:: , SDK (, , boost, , , , boost). , boost:: any, ( boost:: variant ), , SDK RTTI (I ' m , RTTI , - ).
, . , std::string, , factory:: create ( "std::string" ); , , factory std::string .