Make util enum values_range constexpr
This commit is contained in:
parent
84b804adf7
commit
11af452b16
1 changed files with 3 additions and 3 deletions
|
|
@ -48,7 +48,7 @@ namespace psemek::util
|
||||||
|
|
||||||
underlying_type value;
|
underlying_type value;
|
||||||
|
|
||||||
Enum operator *() const { return static_cast<Enum>(value); }
|
constexpr Enum operator *() const { return static_cast<Enum>(value); }
|
||||||
|
|
||||||
enum_iterator operator ++() { ++value; return *this; }
|
enum_iterator operator ++() { ++value; return *this; }
|
||||||
enum_iterator operator ++ (int)
|
enum_iterator operator ++ (int)
|
||||||
|
|
@ -81,7 +81,7 @@ namespace psemek::util
|
||||||
auto rbegin() const { return std::make_reverse_iterator(end()); }
|
auto rbegin() const { return std::make_reverse_iterator(end()); }
|
||||||
auto rend() const { return std::make_reverse_iterator(begin()); }
|
auto rend() const { return std::make_reverse_iterator(begin()); }
|
||||||
|
|
||||||
auto size() const { return last.value - first.value; }
|
constexpr auto size() const { return last.value - first.value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +110,6 @@ namespace psemek::util
|
||||||
} \
|
} \
|
||||||
template <typename Char, typename Traits> \
|
template <typename Char, typename Traits> \
|
||||||
inline ::std::basic_ostream<Char, Traits> & operator << (::std::basic_ostream<Char, Traits> & os, name value) { return os << to_string(value); } \
|
inline ::std::basic_ostream<Char, Traits> & operator << (::std::basic_ostream<Char, Traits> & os, name value) { return os << to_string(value); } \
|
||||||
inline ::psemek::util::enum_range<name> BOOST_PP_CAT(name, _values) () { return {{0}, {BOOST_PP_SEQ_SIZE(values)}}; }
|
constexpr inline ::psemek::util::enum_range<name> BOOST_PP_CAT(name, _values) () { return {{0}, {BOOST_PP_SEQ_SIZE(values)}}; }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue