Code:
$ g++-5 -std=c++14 -o tupleTest tupleTest.cpp
In file included from tupleTest.cpp:4:0:
/usr/include/c++/5/tuple: In instantiation of ‘struct std::tuple_element<1ul, std::tuple<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’:
/usr/include/c++/5/tuple:755:12: recursively required from ‘struct std::tuple_element<2ul, std::tuple<double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’
/usr/include/c++/5/tuple:755:12: required from ‘struct std::tuple_element<3ul, std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’
/usr/include/c++/5/tuple:769:69: required by substitution of ‘template<long unsigned int __i, class _Tp> using __tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 3ul; _Tp = std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’
/usr/include/c++/5/tuple:844:5: required by substitution of ‘template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&) [with long unsigned int __i = 3ul; _Elements = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:48:30: recursively required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with long unsigned int Column = 2ul; Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:48:30: required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with long unsigned int Column = 1ul; Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:58:21: required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:66:32: required from here
/usr/include/c++/5/tuple:755:12: error: invalid use of incomplete type ‘struct std::tuple_element<0ul, std::tuple<> >’
struct tuple_element<__i, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/5/tuple:38:0,
from tupleTest.cpp:4:
/usr/include/c++/5/utility:85:11: note: declaration of ‘struct std::tuple_element<0ul, std::tuple<> >’
class tuple_element;
^
tupleTest.cpp: In instantiation of ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with long unsigned int Column = 3ul; Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’:
tupleTest.cpp:48:30: recursively required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with long unsigned int Column = 2ul; Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:48:30: required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with long unsigned int Column = 1ul; Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:58:21: required from ‘void ParseDbRowTuple(std::vector<std::basic_string<char> >&, std::tuple<_Elements ...>&) [with Args = {int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
tupleTest.cpp:66:32: required from here
tupleTest.cpp:46:46: error: no matching function for call to ‘get(std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:38:0,
from tupleTest.cpp:4:
/usr/include/c++/5/utility:147:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)
get(std::pair<_Tp1, _Tp2>& __in) noexcept
^
/usr/include/c++/5/utility:147:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:38:0,
from tupleTest.cpp:4:
/usr/include/c++/5/utility:152:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)
get(std::pair<_Tp1, _Tp2>&& __in) noexcept
^
/usr/include/c++/5/utility:152:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:38:0,
from tupleTest.cpp:4:
/usr/include/c++/5/utility:157:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)
get(const std::pair<_Tp1, _Tp2>& __in) noexcept
^
/usr/include/c++/5/utility:157:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘const std::pair<_Tp1, _Tp2>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:38:0,
from tupleTest.cpp:4:
/usr/include/c++/5/utility:166:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)
get(pair<_Tp, _Up>& __p) noexcept
^
/usr/include/c++/5/utility:166:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/utility:171:5: note: candidate: template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)
get(const pair<_Tp, _Up>& __p) noexcept
^
/usr/include/c++/5/utility:171:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/utility:176:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)
get(pair<_Tp, _Up>&& __p) noexcept
^
/usr/include/c++/5/utility:176:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/utility:181:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)
get(pair<_Up, _Tp>& __p) noexcept
^
/usr/include/c++/5/utility:181:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/utility:186:5: note: candidate: template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)
get(const pair<_Up, _Tp>& __p) noexcept
^
/usr/include/c++/5/utility:186:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/utility:191:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)
get(pair<_Up, _Tp>&& __p) noexcept
^
/usr/include/c++/5/utility:191:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/tuple:39:0,
from tupleTest.cpp:4:
/usr/include/c++/5/array:280:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)
get(array<_Tp, _Nm>& __arr) noexcept
^
/usr/include/c++/5/array:280:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘std::array<_Tp, _Nm>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:39:0,
from tupleTest.cpp:4:
/usr/include/c++/5/array:289:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)
get(array<_Tp, _Nm>&& __arr) noexcept
^
/usr/include/c++/5/array:289:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘std::array<_Tp, _Nm>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from /usr/include/c++/5/tuple:39:0,
from tupleTest.cpp:4:
/usr/include/c++/5/array:297:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)
get(const array<_Tp, _Nm>& __arr) noexcept
^
/usr/include/c++/5/array:297:5: note: template argument deduction/substitution failed:
tupleTest.cpp:46:46: note: ‘std::tuple<int, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ is not derived from ‘const std::array<_Tp, _Nm>’
ConvertString(row[Column], std::get<Column>(tuple));
^
In file included from tupleTest.cpp:4:0:
/usr/include/c++/5/tuple:832:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)
get(tuple<_Elements...>& __t) noexcept
^
/usr/include/c++/5/tuple:832:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/tuple:838:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)
get(const tuple<_Elements...>& __t) noexcept
^
/usr/include/c++/5/tuple:838:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/tuple:844:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)
get(tuple<_Elements...>&& __t) noexcept
^
/usr/include/c++/5/tuple:844:5: note: substitution of deduced template arguments resulted in errors seen above
/usr/include/c++/5/tuple:867:5: note: candidate: template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)
get(tuple<_Types...>& __t) noexcept
^
/usr/include/c++/5/tuple:867:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/tuple:873:5: note: candidate: template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)
get(tuple<_Types...>&& __t) noexcept
^
/usr/include/c++/5/tuple:873:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/tuple:879:5: note: candidate: template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)
get(const tuple<_Types...>& __t) noexcept
^
/usr/include/c++/5/tuple:879:5: note: template argument deduction/substitution failed:
I've tried it on the three versions of g++that are available to me - g++ 4.6.3, 4.7.2, and 5.3.0, and the code generates errors on all versions. I don't know what I'm doing wrong. I don't have a ton of experience with tuples, but based on info I've found on cppreference.com and other websites, it looks to me like it should work.