I'm using g++-4.6.1 --std=c++0x
and getting a warning I can't seem to decipher with this bit of code:
#include <vector>
#include <tuple>
int main()
{
std::tuple<std::vector<int>, int> t{ {1, 2, 3}, 10};
}
I get the following warning:
scratch.cpp: In function ‘int main()’:
scratch.cpp:6:55: warning: deducing ‘_U1’ as ‘std::initializer_list<int>’ [enabled by default]
/usr/local/include/c++/4.6.1/tuple:329:9: warning: in call to ‘std::tuple<_T1, _T2>::tuple(_U1&&, _U2&&) [with _U1 = std::initializer_list<int>, _U2 = int, _T1 = std::vector<int>, _T2 = int]’ [enabled by default]
scratch.cpp:6:55: warning: (you can disable this with -fno-deduce-init-list) [enabled by default]
Looking at the implementation:
template<typename _T1, typename _T2>
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
{
typedef _Tuple_impl<0, _T1, _T2> _Inherited;
public:
//...
template<typename _U1, typename _U2>
explicit
tuple(_U1&& __a1, _U2&& __a2)
: _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
//...
}
It seems like it is complaining that it is forwarding from the initializer_list<int>
(the {1, 2, 3}
in my code) to the std::vector<int>
which will be the first type in the std::tuple
. This seems totally okay with me.
So my question is: What does this warning mean?