constexpr functions can yield constexpr results even when their arguments are not constexpr, if they are unused. Such is, for example, std::integral_constant::operator T:
#include <utility>
std::integral_constant<int, 42> a;
constexpr int b = a; // Compiles!
How can I make a concept to test this property of a function?
For example, I want the following to work: run on gcc.godbolt.org
#include <utility>
struct A {explicit constexpr operator bool() const {return true;}};
struct B {int x = 1; explicit constexpr operator bool() const {return x;}};
template <typename T>
concept C = requires(T t){std::bool_constant<t>{};};
static_assert(C<A>);
static_assert(!C<B>);
But this gives me:
<source>:7:46: error: constraint variable 't' cannot be used in an evaluated context
7 | concept C = requires(T t){std::bool_constant<t>};
| ^