![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
A compile-time check that a list names every value of an enum, and a parser over the list. More...
#include <array>#include <cstddef>#include <limits>#include <optional>#include <string_view>#include <type_traits>Go to the source code of this file.
Namespaces | |
| namespace | algotradelib |
| The library: broker-neutral types (core), and the modules below. | |
Functions | |
| template<typename Enum, std::size_t N, typename IsEnumerator> | |
| constexpr bool | algotradelib::lists_every_value (const std::array< Enum, N > &values, IsEnumerator is_enumerator) noexcept |
| Tests whether a list holds every value of an enum exactly once, in any order. | |
| template<typename Enum, std::size_t N, typename IsEnumerator> | |
| constexpr bool | algotradelib::lists_every_value (const Enum(&values)[N], IsEnumerator is_enumerator) noexcept |
| Tests whether a list holds every value of an enum exactly once, in any order. | |
| template<typename Enum, std::size_t N, typename Name> | |
| constexpr std::optional< Enum > | algotradelib::value_named (const std::array< Enum, N > &values, Name name, std::string_view text) noexcept |
| Returns the value of a list whose name is text, so a parser reads exactly what its writer writes. | |
A compile-time check that a list names every value of an enum, and a parser over the list.
The library keeps a list of every value next to several enums (all_venues, all_halt_reasons, ...) and derives counts, parsers and tests from it. Each list is checked with lists_every_value in a static_assert, so a value added to the enum and left out of its list fails to compile. value_named reads a name back through the same list.
Definition in file enum_values.hpp.