|
|
|
|
@@ -27,7 +27,7 @@
|
|
|
|
|
# define TOI(n) toi<T>(n)
|
|
|
|
|
# define PRINT(n) print<>(n, #n);
|
|
|
|
|
# define DELETE delete_structs();
|
|
|
|
|
# define DISALLOW_MYSTRUCT allow_mystruct = 0;
|
|
|
|
|
# define AVOID_MYSTRUCT(T) if (is_mystruct_type<T>::value) {return;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prototypes
|
|
|
|
|
@@ -57,9 +57,7 @@ extern std::vector< mystruct* > mem_list;
|
|
|
|
|
add_to_list(#f_name, "int", new(s_ ## f_name <int>));\
|
|
|
|
|
add_to_list(#f_name, "char", new(s_ ## f_name <char>));\
|
|
|
|
|
add_to_list(#f_name, "std::string", new(s_ ## f_name <std::string>));\
|
|
|
|
|
if (allow_mystruct)\
|
|
|
|
|
add_to_list(#f_name, "mystruct*", new(s_ ## f_name <mystruct*>));\
|
|
|
|
|
allow_mystruct = 1;\
|
|
|
|
|
add_to_list(#f_name, "mystruct*", new(s_ ## f_name <mystruct*>));\
|
|
|
|
|
}\
|
|
|
|
|
template <class T>\
|
|
|
|
|
void s_ ## f_name <T>::func()
|
|
|
|
|
@@ -72,20 +70,30 @@ extern std::vector< mystruct* > mem_list;
|
|
|
|
|
add_to_list(#f_name, "char, int", new(s_ ## f_name <char, int>));\
|
|
|
|
|
add_to_list(#f_name, "char, char", new(s_ ## f_name <char, char>));\
|
|
|
|
|
add_to_list(#f_name, "char, std::string", new(s_ ## f_name <char, std::string>));\
|
|
|
|
|
add_to_list(#f_name, "char, mystruct*", new(s_ ## f_name <char, mystruct*>));\
|
|
|
|
|
add_to_list(#f_name, "int, int", new(s_ ## f_name <int, int>));\
|
|
|
|
|
add_to_list(#f_name, "int, char", new(s_ ## f_name <int, char>));\
|
|
|
|
|
add_to_list(#f_name, "int, std::string", new(s_ ## f_name <int, std::string>));\
|
|
|
|
|
add_to_list(#f_name, "int, mystruct*", new(s_ ## f_name <int, mystruct*>));\
|
|
|
|
|
}\
|
|
|
|
|
template <class T, class U>\
|
|
|
|
|
void s_ ## f_name <T, U>::func()
|
|
|
|
|
/*
|
|
|
|
|
add_to_list(#f_name, "char, mystruct*", new(s_ ## f_name <char, mystruct*>));\
|
|
|
|
|
add_to_list(#f_name, "int, mystruct*", new(s_ ## f_name <int, mystruct*>));\
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// templates get value
|
|
|
|
|
// *************************************
|
|
|
|
|
template <class T> struct is_mystruct_type
|
|
|
|
|
{
|
|
|
|
|
typedef char yes[1];
|
|
|
|
|
typedef yes no[2];
|
|
|
|
|
static T type;
|
|
|
|
|
|
|
|
|
|
static yes& test(mystruct*);
|
|
|
|
|
template <class C> static no& test(C);
|
|
|
|
|
static const bool value = sizeof(test(type)) == sizeof(yes);
|
|
|
|
|
};
|
|
|
|
|
// specialization in header, make it inline :
|
|
|
|
|
// https://stackoverflow.com/questions/63529059/c-specialized-method-templates-produce-multiple-definition-errors
|
|
|
|
|
template <class T>
|
|
|
|
|
|