I run into the unfortunate situation that I need to write the following code:
std::map<type1_key, type1_value, type1_cmp> x;
std::map<type2_key, type2_value, type2_cmp> y;
std::map<type3_key, type3_value, type3_cmp> z;
// ...
These key/value/cmp types are predefined for me. Their type names all follow this _key, _value, and _cmp pattern (those are not templates). Is there a built-in way to simplify this into
map_type<type1> x;
// ...
or
map_type(type1) x; // some kind of macro??
// ...
You can use following macro:
#define map_type( x ) std::map<x##_key, x##_value, x##_cmp>
Then,
map_type(type1) x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With