diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-04-02 15:08:59 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-04-02 16:30:33 +0200 |
commit | 0b4965bcd7ec911951e7ca3a4cd48062843b2634 (patch) | |
tree | 4a58c68bc065d01fbad729851b0cbf0037ef2d8e /include | |
parent | 9af6b70fc2f6dd0eacafd8e3bd9d0c2fcbb3ef45 (diff) |
Model o3tl::enumarray after std::array to allow aggregate initialization
...though that requires switching of C++ -Wmissing-braces for Clang and for old
GCC (new GCC already dropped it from C++ -Wall, see
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137#c17>).
Change-Id: I92acc4c529d634c4190e0ee4b65d1fbe5b1b521f
Diffstat (limited to 'include')
-rw-r--r-- | include/o3tl/enumarray.hxx | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx index 89f7e16a6ce1..b476cb3671d2 100644 --- a/include/o3tl/enumarray.hxx +++ b/include/o3tl/enumarray.hxx @@ -21,7 +21,6 @@ #define INCLUDED_O3TL_ENUMARRAY_HXX #include <sal/config.h> -#include <initializer_list> #include <iterator> namespace o3tl { @@ -52,35 +51,27 @@ public: static const size_type max_index = static_cast<size_type>(E::LAST); - /** Create an enumarray with the given elements. - - @param init an initializer_list - */ - enumarray(std::initializer_list<V> init) - { std::copy(init.begin(), init.end(), std::begin(values)); } - - enumarray() {} - const V operator[](E index) const { assert(index>=static_cast<E>(0) && index<=E::LAST); - return values[static_cast<size_type>(index)]; + return detail_values[static_cast<size_type>(index)]; } V& operator[](E index) { assert(index>=static_cast<E>(0) && index<=E::LAST); - return values[static_cast<size_type>(index)]; + return detail_values[static_cast<size_type>(index)]; } void fill(V val) - { for (size_type i=0; i<=max_index; ++i) values[i] = val; } + { for (size_type i=0; i<=max_index; ++i) detail_values[i] = val; } size_type size() const { return max_index + 1; } iterator begin() { return iterator(this, 0); } iterator end() { return iterator(this, size()); } -private: - V values[max_index + 1]; + +//private: + V detail_values[max_index + 1]; }; |