#include <tuple>
template<int I>
struct A {};
template<int I, typename... T>
void f(A<I>, std::tuple<T *...>) {}
template<typename... T>
void f(A<0>, std::tuple<T *...>) {}
int main()
{
f(A<0>{}, std::tuple<char*, int*, float*>{});
}
Isn't the second overload of f
more specialized? g++ 4.9.2 says that the call is ambiguous, clang 3.6.0 accepts it. Which compiler is right?
It's interesting that if you change std::tuple<T *...>
to std::tuple<T...>
, g++ is fine with it, which I don't understand.
Explanation: Tuples can be used for keys into dictionary. The tuples can have mixed length and the order of the items in the tuple is considered when comparing the equality of the keys.
The correct answer to the question “Which of the following is a Python Tuple” is option (B). (1, 2, 3). Because in Python, Tuple is represented in round brackets.
Q 22 - Which of the following is correct about tuples in python? A - A tuple is another sequence data type that is similar to the list.
Incorrect! To create a tuple with a single item, there must be a comma after the first item.
By the current rules, the second overload is more specialized. Some specialization A<@>
with a synthesized value @
cannot be matched against A<0>
, but A<0>
can be matched against A<I>
(with I=0
). This first pair's asymmetry is decisive. Whether you use T
or T*
as the pattern in the second parameter is irrelevant, as deduction succeeds both ways for that pair.
The bug still persists in trunk and was reported by @Barry as 67228.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With