jaulib v1.3.6
Jau Support Library (C++, Java, ..)
|
Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright Gothel Software e.K. More...
Classes | |
class | enum_info |
Enumeration info template class including iterator (enum_iterator) More... | |
class | enum_iterator |
Enumeration iterator, see enum_info. More... | |
struct | is_enum_info |
template< class T > is_enum_info<T>::value compile-time Type Trait, determining whether the given template class is a enum_info type. More... | |
struct | is_enum_info< T, std::void_t< typename T::enum_info_tag > > |
template< class T > is_enum_info<T>::value compile-time Type Trait, determining whether the given template class is a enum_info type. More... | |
struct | NameTable |
struct | ValueTable |
Functions | |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr void | append_bitstr (std::string &out, E mask, E bit, const std::string &bitstr, bool &comma) |
template<typename E, E V> | |
consteval_cxx20 const char * | enum_funcname () noexcept |
clang + gcc | |
template<auto... Vargs> | |
consteval_cxx20 NameTable< Vargs... > | get_names () noexcept |
template<typename... Args> | |
constexpr ValueTable< std::common_type_t< Args... >, sizeof...(Args)> | get_values (Args... args) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr bool | has_any (const E mask, const E bits) noexcept |
template<auto V, std::enable_if_t< std::is_enum_v< decltype(V)> > * = nullptr> | |
consteval_cxx20 bool | is_enum () noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr bool | is_set (const E mask, const E bits) noexcept |
template<auto V, std::enable_if_t< std::is_enum_v< decltype(V)> > * = nullptr> | |
consteval_cxx20 std::string_view | long_name () noexcept |
template<auto V, std::enable_if_t< std::is_enum_v< decltype(V)> > * = nullptr> | |
consteval_cxx20 std::string_view | name () noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr std::underlying_type_t< E > | number (const E v) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr bool | operator!= (const E lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E | operator& (const E lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E & | operator&= (E &lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr std::underlying_type_t< E > | operator* (const E v) noexcept |
template<typename enum_info_t, std::enable_if_t< is_enum_info< enum_info_t >::value > * = nullptr> | |
std::ostream & | operator<< (std::ostream &os, const enum_info_t &v) |
template<typename T, std::enable_if_t< std::is_enum_v< T > > * = nullptr> | |
std::ostream & | operator<< (std::ostream &os, const T v) |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr bool | operator== (const E lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E | operator^ (const E lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E & | operator^= (E &lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E | operator| (const E lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E & | operator|= (E &lhs, const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E | operator~ (const E rhs) noexcept |
template<typename E, std::enable_if_t< std::is_enum_v< E > > * = nullptr> | |
constexpr E & | write (E &store, const E bits, bool set) noexcept |
If set==true , sets the bits in store , i.e. | |
Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright Gothel Software e.K.
SPDX-License-Identifier: MIT
This Source Code Form is subject to the terms of the MIT License If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/license/mit/. Provides scoped enum type support functionality, including to_string
, enum bitfield operations, etc.
Due to lack of C++26 reflection, basic enum function definition is performed via macros to access value names outside constexpr templates.
Overview
enum class
manuallyenum class
helper function generator
JAU_MAKE_ENUM_STRING
, assuming E
is the enum class typeconstexpr std::string_view long_name(const E v) noexcept
E::value
constexpr std::string_view name(const E v) noexcept
value
constexpr std::string to_string(const E v)
value
.JAU_MAKE_BITFIELD_ENUM_STRING
JAU_MAKE_ENUM_STRING
, while to_string(const E v)
returns the set bit values, e.g. [cat, mouse]
constexpr
template functions are available in the jau::enums
namespace, assuming E
is the enum class type, v
an enum value and U
the underlying typeconstexpr U number(const E v) noexcept
constexpr U operator*(const E v) noexcept
number
constexpr bool is_set(const E mask, const E bits) noexcept
true
if mask contains given bits
, otherwise false
constexpr void append_bitstr(std::string& out, E mask, E bit, const std::string& bitstr, bool& comma)
bitstr
to out
if mask
contains bit
, prepends a comma if comma
and sets comma
to true
.constexpr bool operator==(const E lhs, const E rhs) noexcept
constexpr E operator&(const E lhs, const E rhs) noexcept
constexpr std::string_view long_name<auto v>() noexcept
E::value
constexpr std::string_view name<auto v>() noexcept
value
get_names
, get_values