Go to the documentation of this file.
30 #define _detail_ARMARX_MAKE_ENUM_CONVERTERS(...) _detail_ARMARX_MAKE_ENUM_CONVERTERS_i(__VA_ARGS__)
31 #define _detail_ARMARX_MAKE_ENUM_CONVERTERS_i(r, data, elem) case data::elem: return #data "::" #elem;
33 #define ARMARX_MAKE_ENUM_CONVERTERS(type, ...) \
34 static_assert(std::is_enum_v<type>, "Parameters to ARMARX_MAKE_ENUM_CONVERTERS must be enum types"); \
35 inline std::string to_string(type v) \
37 using base = std::underlying_type_t<type>; \
40 ARMARX_VARIADIC_FOR_EACH(_detail_ARMARX_MAKE_ENUM_CONVERTERS, type, __VA_ARGS__) \
42 throw std::invalid_argument{"Unknown enum value " + std::to_string(static_cast<base>(v))}; \
44 inline std::ostream& operator << (std::ostream& out, type v) \
46 return out << to_string(v); \
48 inline type operator++(type& x) {return x = (type)(((int)(x)+1));} \
49 inline type operator++(type& x, int) {type y = x; x = (type)(((int)(x)+1)); return y;}
51 #define ARMARX_MAKE_ENUM_AND_CONVERTERS(name, ...) \
52 enum class name { __VA_ARGS__ }; \
53 ARMARX_MAKE_ENUM_CONVERTERS(name, __VA_ARGS__)