From b9b8339487824c7020130c51ab908cf38be7e17f Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 27 Feb 2025 13:24:13 +0100 Subject: Modernize concepts --- src/utils/cpp/concepts.hpp | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'src/utils/cpp/concepts.hpp') diff --git a/src/utils/cpp/concepts.hpp b/src/utils/cpp/concepts.hpp index d1500e85..ce7ccdec 100644 --- a/src/utils/cpp/concepts.hpp +++ b/src/utils/cpp/concepts.hpp @@ -16,51 +16,31 @@ #define INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP #include +#include #include #include #include #include #include -// TODO(modernize): remove this once std::derived_from is shipped with libcxx -template -concept derived_from = - std::is_base_of_v && - std::is_convertible_v; - -// TODO(modernize): remove this once std::same_as is shipped with libcxx -template -concept same_as = std::is_same_v and std::is_same_v; - template concept ContainsString = requires { typename T::value_type; } and - std::is_same_v; + std::same_as; template -concept HasSize = requires(T const c) { - { - c.size() - } -> same_as; // TODO(modernize): replace by std::same_as -}; +concept HasSize = + requires(T const c) { std::same_as; }; template concept InputIterableContainer = requires(T const c) { - { - c.begin() - } -> same_as; // TODO(modernize): replace by - // std::input_iterator - { - c.end() - } -> same_as; // TODO(modernize): replace by - // std::input_iterator + std::input_iterator; + std::input_iterator; }; template -concept OutputIterableContainer = InputIterableContainer and requires(T c) { - { - std::inserter(c, c.begin()) - } -> same_as>; // TODO(modernize): replace by - // std::output_iterator +concept OutputIterableContainer = requires(T c) { + InputIterableContainer; + std::output_iterator; }; template @@ -82,7 +62,7 @@ template concept StrMapConstForwardIterator = requires(T const c) { { std::remove_reference_t{(*c).first} - } -> same_as; + } -> std::same_as; }; #endif // INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP -- cgit v1.2.3