OmniSciDB
a5dc49c757
|
Macros/templates for defining enum classes and related utilities. Place macro calls in the heavyai namespace so that functions like to_string() can be found by the compiler via ADL. More...
#include <boost/preprocessor.hpp>
#include <algorithm>
#include <array>
#include <optional>
#include <ostream>
#include <string_view>
Go to the source code of this file.
Classes | |
struct | heavyai::StringEnum< Enum > |
struct | heavyai::IsAny< Values > |
Namespaces | |
heavyai | |
Macros | |
#define | HEAVYAI_DEFINE_ENUM_CLASS(enum_class,...) |
#define | HEAVYAI_DEFINE_ENUM_CLASS_WITH_DESCRIPTIONS(enum_class,...) |
#define | HEAVYAI_QUOTE(r, data, i, elem) BOOST_PP_COMMA_IF(i) BOOST_PP_STRINGIZE(elem) |
#define | HEAVYAI_QUOTE_EACH(...) BOOST_PP_SEQ_FOR_EACH_I(HEAVYAI_QUOTE, , BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) |
#define | HEAVYAI_PLUCK_ONE(r, j, i, pair) BOOST_PP_COMMA_IF(i) BOOST_PP_TUPLE_ELEM(2, j, pair) |
#define | HEAVYAI_PLUCK(j,...) BOOST_PP_SEQ_FOR_EACH_I(HEAVYAI_PLUCK_ONE, j, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) |
Functions | |
template<typename Enum , size_t... I> | |
constexpr auto | heavyai::enum_to_array (std::index_sequence< I...>) |
template<typename T , size_t N> | |
constexpr void | heavyai::insertion_sort (std::array< T, N > &arr) |
template<typename Enum > | |
constexpr std::array < StringEnum< Enum >, size_t(Enum::N_)> | heavyai::sort_by_name () |
template<typename Enum > | |
std::optional< Enum > | heavyai::to_enum (std::string_view const name) |
Macros/templates for defining enum classes and related utilities. Place macro calls in the heavyai namespace so that functions like to_string() can be found by the compiler via ADL.
Example: HEAVYAI_DEFINE_ENUM_CLASS(Color, Red, Green, Blue) Defines:
The macro HEAVYAI_DEFINE_ENUM_CLASS_WITH_DESCRIPTIONS() additionally defines
template <typename enum>=""> constexpr std::optional<Enum> to_enum(std::string_view const name); returns the Enum if found by its string representation in O(log(N)) time.
Definition in file define_enum_class.h.
#define HEAVYAI_DEFINE_ENUM_CLASS | ( | enum_class, | |
... | |||
) |
Definition at line 48 of file define_enum_class.h.
#define HEAVYAI_DEFINE_ENUM_CLASS_WITH_DESCRIPTIONS | ( | enum_class, | |
... | |||
) |
Definition at line 62 of file define_enum_class.h.
#define HEAVYAI_PLUCK | ( | j, | |
... | |||
) | BOOST_PP_SEQ_FOR_EACH_I(HEAVYAI_PLUCK_ONE, j, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) |
Definition at line 78 of file define_enum_class.h.
#define HEAVYAI_PLUCK_ONE | ( | r, | |
j, | |||
i, | |||
pair | |||
) | BOOST_PP_COMMA_IF(i) BOOST_PP_TUPLE_ELEM(2, j, pair) |
Definition at line 76 of file define_enum_class.h.
#define HEAVYAI_QUOTE | ( | r, | |
data, | |||
i, | |||
elem | |||
) | BOOST_PP_COMMA_IF(i) BOOST_PP_STRINGIZE(elem) |
Definition at line 73 of file define_enum_class.h.
#define HEAVYAI_QUOTE_EACH | ( | ... | ) | BOOST_PP_SEQ_FOR_EACH_I(HEAVYAI_QUOTE, , BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) |
Definition at line 74 of file define_enum_class.h.