From 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 22 Feb 2022 17:03:21 +0100 Subject: Initial self-hosting commit This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche Co-authored-by: Victor Moreno --- src/utils/cpp/concepts.hpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/utils/cpp/concepts.hpp (limited to 'src/utils/cpp/concepts.hpp') diff --git a/src/utils/cpp/concepts.hpp b/src/utils/cpp/concepts.hpp new file mode 100644 index 00000000..92718b43 --- /dev/null +++ b/src/utils/cpp/concepts.hpp @@ -0,0 +1,55 @@ +#ifndef INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP +#define INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP + +#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_vand std::is_same_v; + +template +concept ContainsString = requires { + typename T::value_type; +} +and std::is_same_v; + +template +concept HasSize = requires(T const c) { + { c.size() } + ->same_as; // TODO(modernize): replace by std::same_as +}; + +template +concept HasToString = requires(T const t) { + { t.ToString() } + ->same_as; // TODO(modernize): replace by 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 +}; + +template +concept OutputIterableContainer = InputIterableContainerand requires(T c) { + { std::inserter(c, c.begin()) } + ->same_as>; // TODO(modernize): replace by + // std::output_iterator +}; + +template +concept InputIterableStringContainer = + InputIterableContainerand ContainsString; + +#endif // INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP -- cgit v1.2.3