summaryrefslogtreecommitdiff
path: root/src/utils/cpp/concepts.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/cpp/concepts.hpp')
-rw-r--r--src/utils/cpp/concepts.hpp40
1 files changed, 10 insertions, 30 deletions
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 <chrono>
+#include <concepts>
#include <cstddef>
#include <ctime>
#include <iterator>
#include <string>
#include <type_traits>
-// TODO(modernize): remove this once std::derived_from is shipped with libcxx
-template <class T, class U>
-concept derived_from =
- std::is_base_of_v<U, T> &&
- std::is_convertible_v<const volatile T*, const volatile U*>;
-
-// TODO(modernize): remove this once std::same_as is shipped with libcxx
-template <class T, class U>
-concept same_as = std::is_same_v<T, U> and std::is_same_v<U, T>;
-
template <class T>
concept ContainsString = requires { typename T::value_type; } and
- std::is_same_v<typename T::value_type, std::string>;
+ std::same_as<typename T::value_type, std::string>;
template <class T>
-concept HasSize = requires(T const c) {
- {
- c.size()
- } -> same_as<std::size_t>; // TODO(modernize): replace by std::same_as
-};
+concept HasSize =
+ requires(T const c) { std::same_as<decltype(c.size()), std::size_t>; };
template <class T>
concept InputIterableContainer = requires(T const c) {
- {
- c.begin()
- } -> same_as<typename T::const_iterator>; // TODO(modernize): replace by
- // std::input_iterator
- {
- c.end()
- } -> same_as<typename T::const_iterator>; // TODO(modernize): replace by
- // std::input_iterator
+ std::input_iterator<decltype(c.begin())>;
+ std::input_iterator<decltype(c.end())>;
};
template <class T>
-concept OutputIterableContainer = InputIterableContainer<T> and requires(T c) {
- {
- std::inserter(c, c.begin())
- } -> same_as<std::insert_iterator<T>>; // TODO(modernize): replace by
- // std::output_iterator
+concept OutputIterableContainer = requires(T c) {
+ InputIterableContainer<T>;
+ std::output_iterator<decltype(c.begin()), typename T::value_type>;
};
template <class T>
@@ -82,7 +62,7 @@ template <typename T>
concept StrMapConstForwardIterator = requires(T const c) {
{
std::remove_reference_t<decltype((*c).first)>{(*c).first}
- } -> same_as<std::string const>;
+ } -> std::same_as<std::string const>;
};
#endif // INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP