diff --git a/src/Lib/Utils.hh b/src/Lib/Utils.hh index 9c223677d48a67f71f5930f31dd5f9cec5e29e8f..66d6507cdae6fe2b894b8148d3068bd3c5c5b8e6 100644 --- a/src/Lib/Utils.hh +++ b/src/Lib/Utils.hh @@ -26,6 +26,7 @@ // Use chrono instead of std::chrono... namespace chrono = std::chrono; +using chrono::duration_cast; // Prety define for OpenMP's parallel for loop with indentation not fucked up // by clang-format. @@ -58,8 +59,23 @@ concept PropertyConstViewable = requires(T element) // clang-format on }; +// Concept with a better name for inheritence between types template <class T, class U> concept Derived = std::is_base_of<U, T>::value; + +// Concept for string things +template <typename T> +concept StringType = requires(T str) +{ + // clang-format off + typename T::iterator; // Can iterate + typename T::value_type; // The `Char` + { str.size() } -> std::convertible_to<std::size_t>; + { str.begin() } -> std::same_as<typename T::iterator>; + { str.end() } -> std::same_as<typename T::iterator>; + { str[0] } -> std::same_as<typename T::value_type>; + // clang-format on +}; } namespace Vivy::Utils