From fa7eb205d5f18b72c1e04a4229d171a15040bdea Mon Sep 17 00:00:00 2001 From: johannst Date: Fri, 30 Sep 2022 10:58:40 +0000 Subject: deploy: b6f25b16f1f23b0169e8f076e79ee4964b81db99 --- development/c++/concepts-11.cc | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 development/c++/concepts-11.cc (limited to 'development/c++/concepts-11.cc') diff --git a/development/c++/concepts-11.cc b/development/c++/concepts-11.cc new file mode 100644 index 0000000..888ff4d --- /dev/null +++ b/development/c++/concepts-11.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2022 johannst +#include + +template class Checker, typename = void> +struct is_valid : std::false_type {}; + +template class Checker> +struct is_valid>> : std::true_type {}; + +template class Checker> +static constexpr bool is_valid_v = is_valid::value; + +// ----------------------------------------------------------------------------- + +template class Checker, typename = void> +struct is_valid_with_ret : std::false_type {}; + +template class Checker> +struct is_valid_with_ret>> : std::is_same> {}; + +template class Checker> +static constexpr bool is_valid_with_ret_v = is_valid_with_ret::value; + +// ----------------------------------------------------------------------------- + +template +struct is_entry { + template + using init = decltype(std::declval().init()); + template + using tag = decltype(std::declval().tag()); + template + using val = decltype(std::declval().val()); + + static constexpr bool value = is_valid_v && + is_valid_with_ret_v && + is_valid_with_ret_v; +}; + +template +static constexpr bool is_entry_v = is_entry::value; + +template +struct Entry { + using Type = E; + void init(); + int tag() const; + E val() const; +}; + +int main() { + static_assert(is_entry_v>, ""); +} -- cgit v1.2.3