X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6b56c15c3ec34841fae10fa42a656aec029d27e9..639c6962daa378323864a53174e0e7fe2fcaef1e:/include/xbt/utility.hpp diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index 03458064d3..bb599d6c29 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,6 +25,10 @@ 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 { @@ -76,6 +80,6 @@ template inline void intrusive_erase(List& list, Elem& list.erase(list.iterator_to(elem)); } -} -} +} // namespace xbt +} // namespace simgrid #endif