Wie kann ich überprüfen, ob ein Funktionsergebnis Constexpr ist, auch wenn das Argument nicht ist?
Posted: 25 Feb 2025, 09:29
Code: Select all
constexpr
Code: Select all
#include
std::integral_constant a;
constexpr int b = a; // Compiles!
Code: Select all
#include
struct A {explicit constexpr operator bool() const {return true;}};
struct B {int x = 1; explicit constexpr operator bool() const {return x;}};
template
concept C = requires(T t){std::bool_constant{};};
static_assert(C);
static_assert(!C);
< /code>
Aber das gibt mir: < /p>
:7:46: error: constraint variable 't' cannot be used in an evaluated context
7 | concept C = requires(T t){std::bool_constant};
| ^