Since the actual type value does not matter, I would suggest using int{} as an argument. In this document, the purpose of the argument is somewhat better, IMO:
{ a.bar(int{}) } -> int;
Obviously, this will not work with types for which there is no default constructor. In templates, you can use std::declval to work on a similar problem, but here are the GCC errors:
error: static assertion failed: declval() must not be used!
But there is nothing that would prevent us from writing an equivalent (but not implemented) function that will be used with concepts, for example:
#include <type_traits> template <class T> typename std::add_rvalue_reference<T>::type makeval(); template<typename T> concept bool myConcept() { return requires(T a, int i) { { a.foo() } -> int; { a.bar(makeval<int>()) } -> int; }; } struct Object { int foo() {return 0;} int bar(int) {return 0;} }; static_assert(myConcept<Object>(), "Object does not adhere to myConcept");
source share