I was wondering if there was a clean method to extract types from __VA_ARGS__
and use them to fill template method or structure definitions?
Thanks in advance
I have the following problem:
my macro definition:
#define MY_MACRO(topic, callback_name, message_type, ...) \
Callback_data<message_type, ##__VA_ARGS__> callback_name##_data(callback_name, topic); \
Handler::add_callback<message_type, ##__VA_ARGS__>(callback_name##_data)
my macro call:
MY_MACRO("/my_topic_1", callback_1, bool, int a, int b);
what I'd like my macro writes:
Callback_data<bool, int, int> callback_1_data(callback_1, "/my_topic_1");
Handler::add_callback<bool, int, int>(callback_1_data);
what my macro actually writes:
Callback_data<bool,int a, int b> callback_1_data(callback_1, "/my_topic_1");
Handler::add_callback<bool,int a, int b>(callback_1_data);
//! error on both lines, template filling expecting only type definitions !
PS : If anyone knows of a modern way to do the same thing without using macros, I'm interested too!