template<typename EA> class enumarray_iterator; template<typename EA> class enumarray_const_iterator;
/// /// This is a container convenience class for arrays indexed by enum values. /// /// This assumes that the 'enum class' definition /// - starts at zero /// - has no holes in its sequence of values /// - defines a value called LAST which refers to the greatest constant. /// /// \param E the 'enum class' type. /// \param V the value type to be stored in the array template<typename E, typename V> class enumarray final
{ public: typedef enumarray<E, V> self_type; typedef enumarray_iterator<self_type> iterator; typedef enumarray_const_iterator<self_type> const_iterator;
typedef V value_type; typedef E key_type; typedef size_t size_type;
// If this ctor only had the args parameter pack, it would erroneously get picked as a better // choice than the (implicit) copy ctor (taking a const lvalue reference) when a copy is made // from a non-const lvalue enumarray; the easiest way to avoid that is the additional arg // parameter; and to keep things simple that parameter is always passed by const lvalue // reference for now even if there could be cases where passing it by rvalue reference might be // beneficial or even necessary if V is a move-only type: template<typename... T> constexpr enumarray(V const & arg, T && ...args):
detail_values{arg, std::forward<T>(args)...}
{
static_assert(sizeof... (T) == max_index);
}
// coverity[uninit_ctor] - by design:
enumarray() {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.