I wonder if we could have class like this (pseudocode):
template <class Arg1T, ... class ArgNT>
class my_class
{
public:
my_class(Arg1T Arg1, std::string Arg1_name ... ArgNT ArgN, std::string ArgN_name){}
};
And if we could auto generate a function for each provided argument type on compile time using defines for example to get something like (pseudocode):
template <class Arg1T, ... class ArgNT>
class my_class
{
public:
my_class(Arg1T Arg1, std::string Arg1_name ... ArgNT ArgN, std::string ArgN_name){}
// for each Arg we want to create a function like
ArgMT my_class_function(std::string name)
{
if(name == ArgM_name)
return ArgM;
}
};
Is such/or a bit similar thing possible in modern C++ and how to create it?
What I try to say is: I want to generate functions, for each class type provided to constructor from some function template. And wonder how to do such thing? Here is shown how to repeat but how to repeat over provided to class arguments and thare types?
What I meant was if we'd know ammount of class templete arguments (N
) we could create N
variables of difrent types (one for each argument) and N
strings (all private) and so we could create N
functions for setters and getters of that (strings + variables) (which we would call in constructor). Main problem here is - how to solve times when you get same types twice or more, haw to get ammount of args from boost.preprocessor, how to filter same types?