Leggendo qualche codice sorgente, ho trovato tratti prossima definizione:Definizione di tratti di tipo. Tratti blob & METAFUNCTIONS
namespace dds {
template <typename Topic> struct topic_type_support { };
template <typename Topic> struct topic_data_writer { };
template <typename Topic> struct topic_data_reader { };
template <typename Topic> struct topic_data_seq { };
}
#define REGISTER_TOPIC_TRAITS(TOPIC) \
namespace dds { \
template<> struct topic_type_support<TOPIC> { \
typedef TOPIC##TypeSupport type; }; \
template<> struct topic_data_writer<TOPIC> { \
typedef TOPIC##DataWriter type; }; \
template<> struct topic_data_reader<TOPIC> { \
typedef TOPIC##DataReader type; }; \
template<> struct topic_data_seq<TOPIC> { \
typedef TOPIC##Seq type; }; \
}
che sembra strano per me. Avrei raggruppato tutte le caratteristiche di una classe unica come questa:
namespace dds {
template <typename Topic> struct topic_traits { };
}
#define REGISTER_TOPIC_TRAITS(TOPIC) \
namespace dds { \
template<> struct topic_traits<TOPIC> { \
typedef TOPIC##TypeSupport type_support; \
typedef TOPIC##DataWriter data_writter; \
typedef TOPIC##DataReader data_reader; \
typedef TOPIC##Seq seq_type; \
}; \
}
Chi di voi a capire perché secondo approccio potrebbe essere più fragile rispetto al primo o significativamente più difficile aggiungere nuovi tratti?
Per ulteriori informazioni sulla meta programmazione google Boost MPL – KitsuneYMG
@ Samuel: Tracce di blob. Questo è il nome che stavo cercando! Grazie. Ho già ordinato il libro di Abrahams. –