I have the following code from Ben Deane talk.
#define CX_VALUE(...) [] { \
struct { \
constexpr auto operator()() const noexcept { return __VA_ARGS__; } \
using cx_value_tag = void; \
} val; \
return val; \
}()
template <typename T>
concept cx_value = requires { typename T::cx_value_tag; };
auto func(cx_value auto x) {
constexpr auto val = x();
std::cout << "Constexpr value: " << val.val() << '\n';
}
class S {
public:
constexpr S(const int val) : val_(val){}
int val() const {
return val_;
}
private:
int val_;
};
int main() {
constexpr S non_structural_value{420};
func(CX_VALUE(non_structural_value));
}
Issue is that clang rejects it, gcc accepts it.
Which compiler is right(or is it maybe underspecified in the standard)?
non_structural_valuedeclaration and thus throw an error.