From 11af452b16957fe00934af3916426f255ae9efd8 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 25 Feb 2023 12:42:36 +0300 Subject: [PATCH] Make util enum values_range constexpr --- libs/util/include/psemek/util/enum.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/util/include/psemek/util/enum.hpp b/libs/util/include/psemek/util/enum.hpp index 6ba649e5..76a4ae04 100644 --- a/libs/util/include/psemek/util/enum.hpp +++ b/libs/util/include/psemek/util/enum.hpp @@ -48,7 +48,7 @@ namespace psemek::util underlying_type value; - Enum operator *() const { return static_cast(value); } + constexpr Enum operator *() const { return static_cast(value); } enum_iterator operator ++() { ++value; return *this; } enum_iterator operator ++ (int) @@ -81,7 +81,7 @@ namespace psemek::util auto rbegin() const { return std::make_reverse_iterator(end()); } 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 \ inline ::std::basic_ostream & operator << (::std::basic_ostream & os, name value) { return os << to_string(value); } \ - inline ::psemek::util::enum_range BOOST_PP_CAT(name, _values) () { return {{0}, {BOOST_PP_SEQ_SIZE(values)}}; } + constexpr inline ::psemek::util::enum_range BOOST_PP_CAT(name, _values) () { return {{0}, {BOOST_PP_SEQ_SIZE(values)}}; }