/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
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 ist noch experimentell.