I have some code which tries to use a concept to specify requirements on the member functions of a class:
#include <type_traits>
template <typename A>
concept MyConcept = requires(A a, bool b) {
{ a.one() } -> bool;
a.two();
a.three(b);
};
Unfortunately, clang 10.0.0 using -std=c++20
on https://godbolt.org produces an error:
<source>:5:18: error: expected concept name with optional arguments [clang-diagnostic-error]
{ a.one() } -> bool;
^
Does anyone have a handle on the syntax clang is expecting? I've tried a number of variants based on samples from various sources, such as this Compound Requirements sample, but no luck so far:
#include <type_traits>
template<typename T> concept C2 =
requires(T x) {
{*x} -> std::convertible_to<typename T::inner>; // the expression *x must be valid
// AND the type T::inner must be valid
// AND the result of *x must be convertible to T::inner
{x + 1} -> std::same_as<int>; // the expression x + 1 must be valid
// AND std::same_as<decltype((x + 1)), int> must be satisfied
// i.e., (x + 1) must be a prvalue of type int
{x * 1} -> std::convertible_to<T>; // the expression x * 1 must be valid
// AND its result must be convertible to T
};
Any help appreciated.