-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
Hi,
While playing with the new splice syntax (beautiful, btw), I ran into this curiosity:
using info = decltype(reflexpr(void));
template<info V>
constexpr auto get()
{
return [<V>];
}
template<typename T>
constexpr auto copy_indirect(T&& t)
{
// IFF we are trying to obtain a constexpr value from this function, this fails:
return get<reflexpr(t)>();
// "function parameter 't' with unknown value cannot be used in a constant expression"
}
template<typename T>
constexpr auto copy_semi_direct(T&& t)
{
constexpr auto i = reflexpr(t); // No problem here
return [<i>];
}
template<typename T>
constexpr auto copy_direct(T&& t)
{
return [<reflexpr(t)>]; // No problem here
}
int main(int argc, char**argv)
{
auto a = copy_indirect(1); // Works
auto b = copy_indirect(argc); // Works
constexpr auto x = copy_indirect(1); // Fails
constexpr auto y = copy_semi_direct(1); // Works
constexpr auto z = copy_direct(1); // Works
}Reactions are currently unavailable