Closed jasiolpn closed 2 months ago
Hey Marcin! I believe you ran into a corner case that we learned about this week during Core wording review. There are three contexts in the language, that we know of, when an id-expression can be a prvalue: 1) when making a non-type template parameter of non-class type, 2) when naming an enumerator, and as we found out this week, 3) pack index expressions. I think we need some special handling for the last case.
Thank you for the reply. I developed workaround for my problem which works, but it needs some boilerplate code, is less readable and (in my opinion most important) is not efficient as it should be:
template <std::size_t ACount, std::size_t BCount, auto... Sayers>
struct Greeter
{
auto operator()() const noexcept -> void
{
const auto tuple = std::make_tuple([: Sayers :]...);
[&tuple] <auto... Indexes> (std::index_sequence<Indexes...>) {
std::apply(
[] (auto&& ...sayers) -> void {
((sayers...[Indexes].sayHello()), ...);
},
tuple
);
}(std::make_index_sequence<ACount>{});
[&tuple] <auto... Indexes> (std::index_sequence<Indexes...>) {
std::apply(
[] (auto&& ...sayers) -> void {
((sayers...[Indexes + ACount].sayOtherHello()), ...);
},
tuple
);
}(std::make_index_sequence<BCount>{});
}
};
It requires instantiation of std::tuple
so we are losing constexpr
ness of the Sayers
arguments.
Anyway I hope problems with wording will be resolved soon!
~Hey Marcin! I believe you ran into a corner case that we learned about this week during Core wording review. There are three contexts in the language, that we know of, when an id-expression can be a prvalue: 1) when making a non-type template parameter of non-class type, 2) when naming an enumerator, and as we found out this week, 3) pack index expressions. I think we need some special handling for the last case.~
Lol I think the reason is unrelated to this. Hope to have a fix shortly, though.
Turned out to be a bug in substitution of reflection non-type template arguments - the bug was introduced when I removed support for the ^cast-expression
form that was supported up until P2996R3. Thanks for the report! This should work on Godbolt tomorrow.
Hello First of all thank you for incredible work you have done. I am very excited about reflection features in C++.
I was playing a little with C++26 features implemented in Clang. One of them is pack indexing. I decided to check how it works with reflection. I wrote simple program (without reflection fatures) which works as expected:
Output:
But if I change
Sayers
parameters ofstruct Greeter
to be reflections it fails to compile:Compiler output:
However code compiles if I will manually expand fold expressions:
Output:
I believe that second code snippet should be valid and there is a bug in a compiler.
Best regards! Marcin Nowak