X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6b56c15c3ec34841fae10fa42a656aec029d27e9..bfffef69e1b0554d13eec920f1a32f75b49ceac6:/include/xbt/utility.hpp diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index 03458064d3..c35be72d7f 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2022. The SimGrid Team. +/* Copyright (c) 2016-2023. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -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