Question for standard gurus.
Trying to respond to another question, I came to doubt about the well-formedness of a code.
As far I know, the following code is ill-formed
int main ()
{
std::tuple<> a;
std::get<0>(a);
}
because a call to std::get<I>(t)
, when t
is a std::tuple<Ts...>
, is ill-formed when I
is outside the range [0, sizeof...(Ts)[
.
In this case sizeof...(Ts)
is zero, so the range [0, 0[
is empty, so std::get<I>(a)
is ill-formed for every index I
.
But when std::get<I>(a)
is expanded through an empty variadic pack?
I mean: the following code
#include <tuple>
template <typename ... Args>
void bar (Args const & ...)
{ }
template <std::size_t ... I>
void foo ()
{
std::tuple<> a;
bar( std::get<I>(a) ... );
}
int main ()
{
foo<>();
}
that uses a ill-formed (?) call (std::get<I>(a)
) but zero-time variadic expanded (sizeof...(I)
is zero), is well-formed or ill-formed?
Aucun commentaire:
Enregistrer un commentaire