------- Comment #2 from paolo dot carlini at oracle dot com 2010-08-07 22:19
-------
Our std::tuple still needs work, but I see am inconsistency here between the
variadic and the non variadic case which I don't understand, irrespective of
library details. Consider the following reduced testcase: it outputs *only*
"Two (m)", no "Two (2)". It seems pretty obvious to me that the constructor
"Two", which takes *individual elements*, certainly should never be involved,
but it is, in the variadic case only.
Jason can you have a look? Thanks in advance!
///////////
#include <iostream>
template<typename... Types>
struct tuple_m
{
tuple_m() { }
explicit
tuple_m(const Types&...)
{ std::cout << "One (m)\n"; }
template<typename... UTypes>
explicit
tuple_m(UTypes&&...)
{ std::cout << "Two (m)\n"; }
tuple_m(const tuple_m&)
{ std::cout << "Three (m)\n"; }
tuple_m(tuple_m&&)
{ std::cout << "Four (m)\n"; }
template<typename... UTypes>
tuple_m(const tuple_m<UTypes...>&)
{ std::cout << "Five (m)\n"; }
template<typename... UTypes>
tuple_m(tuple_m<UTypes...>&&)
{ std::cout << "Six (m)\n"; }
};
template<typename T1, typename T2>
struct tuple_2
{
tuple_2() { }
explicit
tuple_2(const T1&, const T2&)
{ std::cout << "One (2)\n"; }
template<typename UT1, typename UT2>
explicit
tuple_2(UT1&&, UT2&&)
{ std::cout << "Two (2)\n"; }
tuple_2(const tuple_2&)
{ std::cout << "Three (2)\n"; }
tuple_2(tuple_2&&)
{ std::cout << "Four (2)\n"; }
template<typename UT1, typename UT2>
tuple_2(const tuple_2<UT1, UT2>&)
{ std::cout << "Five (2)\n"; }
template<typename UT1, typename UT2>
tuple_2(tuple_2<UT1, UT2>&&)
{ std::cout << "Six (2)\n"; }
};
typedef tuple_2<int, int> tuple_2_type;
typedef tuple_m<int, int, int> tuple_m_type;
const tuple_2_type f2() { return tuple_2_type(); }
const tuple_m_type fm() { return tuple_m_type(); }
int main()
{
tuple_2_type test_2(f2());
tuple_m_type test_m(fm());
}
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo dot carlini at oracle
| |dot com, jason at gcc dot
| |gnu dot org
Summary|Can't copy-construct |[C++0x] Can't copy-construct
|"tuple<int,int,int>" from |"tuple<int,int,int>" from
|"const tuple<int,int,int>" |"const tuple<int,int,int>"
|rvalue |rvalue
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45228