X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5ed37babb2fa9097abe82df299c0aa259ed84d5a..a0d47b6eaf07218a602ed6606da925fbd3629909:/include/xbt/utility.hpp?ds=sidebyside diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index 34dc34e92a..c35be72d7f 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -25,10 +25,13 @@ constexpr std::array names{{_XBT_STRINGIFY_ARGS(__VA_ARGS__)}}; \ return names.at(static_cast(value)); \ } \ + static constexpr bool is_valid_##EnumType(int raw_value) \ + { \ + return raw_value >= 0 && raw_value < _XBT_COUNT_ARGS(__VA_ARGS__); \ + } \ enum class EnumType { __VA_ARGS__ } /* defined here to handle trailing semicolon */ -namespace simgrid { -namespace xbt { +namespace simgrid::xbt { /** @brief Replacement for C++20's std::type_identity_t */ @@ -76,6 +79,5 @@ template inline void intrusive_erase(List& list, Elem& list.erase(list.iterator_to(elem)); } -} -} +} // namespace simgrid::xbt #endif