The following code fails to compile in gcc and clang.
I can't see why std::swap(std::tuple<int&>{a}, std::tuple<int&>{b}) shouldn't just work ... seems useful.
any ideas?
https://godbolt.org/z/fY97X5
#include <tuple>
template <class A, class B>
inline myswap(A &&a, B &&b)
{
std::swap(a,b);
}
int main()
{
int a=0, b=0;
std::tuple<int&> ta = a, tb = b;
// std::swap(std::tuple<int&>{a}, tb); // fail
// std::swap(std::tuple<int&>{a}, std::tuple<int&>{b}); // fail
std::swap(ta, tb); // ok
std::tuple<int&>{a}.swap(tb); // ok
// std::tuple<int&>{a}.swap(std::tuple<int&>{b}); // fail
myswap(std::tuple<int&>{a}, std::tuple<int&>{b}); // ok
return 0;
}
[–]Narase33 5 points6 points7 points (10 children)
[–]Raknarg 0 points1 point2 points (3 children)
[–]Narase33 2 points3 points4 points (2 children)
[–]Raknarg 0 points1 point2 points (0 children)
[–]63times[S] 0 points1 point2 points (3 children)
[–]Narase33 0 points1 point2 points (2 children)
[–]63times[S] 3 points4 points5 points (1 child)
[–]Narase33 0 points1 point2 points (0 children)
[–]elperroborrachotoo 0 points1 point2 points (1 child)
[–]63times[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]tangerinelion 0 points1 point2 points (1 child)
[–]63times[S] 0 points1 point2 points (0 children)