From the accepted answer of the previous question, I found a rule. I did not know about templates and the correct form.
The program is poorly formed, diagnostics are not required if:
- [...]
- Any actual specialization of a variational template requires an empty package of template parameters or
- [...]
According to this rule (if I understand correctly), the following template function is poorly formed
template <typename ... Ts>
int foo (std::tuple<Ts...> const &)
{ return std::get<sizeof...(Ts)>(std::tuple<int>{42}); }
since only a valid specialization and an empty parameter package are required Ts...
.
But (maybe because I do not know English very well). I'm not sure I understand this rule in the case of a template with two packages of additional packages.
I mean ... the following function foo()
#include <tuple>
#include <iostream>
template <typename ... Ts, typename ... Us>
int foo (std::tuple<Ts...> const &, std::tuple<Us...> const &)
{ return std::get<sizeof...(Ts)+sizeof...(Us)-1U>(std::tuple<int>{42}); }
int main ()
{
auto t0 = std::tuple<>{};
auto t1 = std::tuple<int>{0};
std::cout << foo(t0, t1) << std::endl;
std::cout << foo(t1, t0) << std::endl;
}
?
, Ts...
Us...
( 1).
, , , - ( , ) , , , ( )?