C++

'std::tuple' Is Not a Member of 'std' Fix

std::tuple lives in one header, , and in language modes from C++11 onward. Miss the header and the name is not a member of std, with a note naming the header to add; compile in an older mode and the library headers refuse with a #error first - and the headers probed in this guide's sweep only half-rescue the name, changing the error to an incomplete type instead of removing it.

Written November 29, 2026 · Tested with GCC 13.3.0 · 17 min read

By the end of this guide
  • The rule underneath: one header, C++11 or later
  • The first failure: no <tuple> include
  • The same failure at namespace scope: does not name a template type
  • The second failure: <tuple> included, compiled as C++98

Written November 29, 2026

Tested with GCC 13.3.0

What this guide is

The error on a std::tuple name means the compiler has no tuple name inside std to find. Inside a function, GCC words it exactly as this guide's title promises: 'tuple' is not a member of 'std'. The common cause is a missing include: nothing in the file included <tuple>, the header that declares the name, so the lookup fails at the first use. The second cause is the language mode: std::tuple is since C++11, so a file compiled in an older mode gets no std::tuple either - and that shape announces itself differently, with a #error from inside the library headers before the same not-a-member errors follow.

The wording also changes with where the failing name sits. At namespace scope, where the name is used as a type for a variable declaration, GCC reports 'tuple' in namespace 'std' does not name a template type instead - note the word "template": this name is a class template, and the namespace-scope wording says so, where the same fault on a non-template name is worded as "does not name a type". Both wordings appear below; they are one fault - the name is absent - read at two different positions in the file.

Unlike some other missing names, this error does carry its remedy with it: GCC attaches a note to the std::tuple error naming the header to add - 'std::tuple' is defined in header '<tuple>'; did you forget to '#include <tuple>'? Read the note before anything else in the cascade, because it is the diagnosis and the fix in one line. And where some names are rescued outright by accident when a neighboring header pulls their declarations in, the sweep below finds only a half-rescue for std::tuple: the probed headers declare the name without defining it, and the error changes shape instead of going away. The fix stays direct either way: #include <tuple> in the file itself, plus a language mode of C++11 or later.

The rule underneath: one header, C++11 or later

The std::tuple page dates the type: the class template tuple is since C++11, a fixed-size collection of heterogeneous values, and a generalization of std::pair. There is no C++03 form of std::tuple: the type arrived with the 2011 standard.

The header page shows what the header declares, all in namespace std and all since C++11 unless a later date is shown: the tuple class template, the tuple_size and tuple_element helper class templates with their specializations for std::tuple, the ignore constant, and the function templates make_tuple, tie, forward_as_tuple, tuple_cat and get. The std::get page for tuples gives the access rule this guide's programs use, with the same date: the index form of std::get is since C++11, it extracts the Ith element from the tuple, and I must be an integer value in [0, sizeof...(Types)) - in range, which is the boundary one of the neighboring-error sections below crosses. std::make_tuple, on the std::tuple page's non-member list, is also since C++11 and creates a tuple object of the type defined by the argument types, and std::tuple_size<std::tuple> obtains the size of a tuple. So a std::tuple name needs both conditions at once: the header included, so the declarations are in the file, and a language mode of C++11 or later, so the header is allowed to declare them.

The first failure: no <tuple> include

This program uses std::tuple and std::get and includes no header at all - deliberately, because a companion header would be its own possible rescue, and the sweep below measures each candidate header on its own instead:

C++
int main() {
    std::tuple<int, double> t(1, 2.5);
    return std::get<0>(t) == 1 ? 0 : 1;
}
Terminal
$ g++ -std=c++11 p1_fail_no_include.cpp -o p1_fail_no_include
p1_fail_no_include.cpp: In function 'int main()':
p1_fail_no_include.cpp:2:10: error: 'tuple' is not a member of 'std'
    2 |     std::tuple<int, double> t(1, 2.5);
      |          ^~~~~
p1_fail_no_include.cpp:1:1: note: 'std::tuple' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
  +++ |+#include <tuple>
    1 | int main() {
p1_fail_no_include.cpp:2:16: error: expected primary-expression before 'int'
    2 |     std::tuple<int, double> t(1, 2.5);
      |                ^~~
p1_fail_no_include.cpp:3:17: error: 'get' is not a member of 'std'
    3 |     return std::get<0>(t) == 1 ? 0 : 1;
      |                 ^~~
p1_fail_no_include.cpp:3:24: error: 't' was not declared in this scope
    3 |     return std::get<0>(t) == 1 ? 0 : 1;
      |                        ^

Read the note first: it sits directly under the title error and names the header, so this shape diagnoses itself - the include is missing, and the note says which one. The errors that follow are the cascade from that one absence. expected primary-expression before 'int' is the compiler trying to read std::tuple<int, double> as something other than a template name, because the template name is not there. 'get' is not a member of 'std' is the same absence one line down: std::get for tuples lives in the same header, so it fails the same way. And 't' was not declared in this scope is fallout: the declaration failed, so the variable does not exist where it is used. The language mode here is already C++11, so the mode is not the problem in this shape; the missing header is.

The same failure at namespace scope: does not name a template type

The same missing include at namespace scope is worded differently. This program declares the tuple as a file-scope variable, still with no header:

C++
std::tuple<int, double> g_t(1, 2.5);

int main() {
    return std::get<0>(g_t) == 1 ? 0 : 1;
}
Terminal
$ g++ -std=c++11 p1b_fail_scope.cpp -o p1b_fail_scope
p1b_fail_scope.cpp:1:6: error: 'tuple' in namespace 'std' does not name a template type
    1 | std::tuple<int, double> g_t(1, 2.5);
      |      ^~~~~
p1b_fail_scope.cpp:1:1: note: 'std::tuple' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
  +++ |+#include <tuple>
    1 | std::tuple<int, double> g_t(1, 2.5);
p1b_fail_scope.cpp: In function 'int main()':
p1b_fail_scope.cpp:4:17: error: 'get' is not a member of 'std'
    4 |     return std::get<0>(g_t) == 1 ? 0 : 1;
      |                 ^~~
p1b_fail_scope.cpp:4:24: error: 'g_t' was not declared in this scope
    4 |     return std::get<0>(g_t) == 1 ? 0 : 1;
      |                        ^~~

Same fault, different first line: where the name is used as a type outside a function, GCC says it does not name a template type; where it is used inside a function, GCC says it is not a member of std. The wording is worth recognizing exactly, because "does not name a template type" is this name's namespace-scope form - a non-template name in the same position is reported as "does not name a type", without the word "template". The header note appears here too, unchanged, naming <tuple> as the remedy, and the std::get error and the undeclared-variable error follow inside main exactly as in the function-scope shape. Recognize either wording as the missing-include shape.

The second failure: <tuple> included, compiled as C++98

The same use of the library with the header included still fails when the language mode is older than the library - and here the first diagnostic is not the title error at all, but a refusal from inside the library headers:

C++
#include <tuple>
#include <iostream>

int main() {
    std::tuple<int, double> t(1, 2.5);
    std::cout << std::get<0>(t) << " " << std::get<1>(t) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++98 p2_included.cpp -o p2_cpp98
In file included from /usr/include/c++/13/tuple:35,
                 from p2_included.cpp:1:
/usr/include/c++/13/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p2_included.cpp: In function 'int main()':
p2_included.cpp:5:10: error: 'tuple' is not a member of 'std'
    5 |     std::tuple<int, double> t(1, 2.5);
      |          ^~~~~
p2_included.cpp:5:10: note: 'std::tuple' is only available from C++11 onwards
p2_included.cpp:5:16: error: expected primary-expression before 'int'
    5 |     std::tuple<int, double> t(1, 2.5);
      |                ^~~
p2_included.cpp:6:23: error: 'get' is not a member of 'std'
    6 |     std::cout << std::get<0>(t) << " " << std::get<1>(t) << "\n";
      |                       ^~~
p2_included.cpp:6:30: error: 't' was not declared in this scope; did you mean 'tm'?
    6 |     std::cout << std::get<0>(t) << " " << std::get<1>(t) << "\n";
      |                              ^
      |                              tm
p2_included.cpp:6:48: error: 'get' is not a member of 'std'
    6 |     std::cout << std::get<0>(t) << " " << std::get<1>(t) << "\n";
      |                                                ^~~

The #error is the tell: it comes from the library's own headers, names the 2011 standard as the requirement, and names the remedy - enable -std=c++11 or -std=gnu++11. The include is present and correct, and adding it again changes nothing; the mode is the fault. This shape also carries a different note from the missing-include shape: under the title error here, the note reads 'std::tuple' is only available from C++11 onwards - not the "did you forget to include" note, because the include is already there and the mode is what is missing. The not-a-member errors still follow underneath, because with the header's contents withheld the names are absent exactly as in the missing-include shape - which is why reading only the later errors misleads: scroll to the first diagnostic, and if it is this #error, the compile line is what to fix. At -std=c++03 this exact program fails identically, line for line - same #error, same note, same not-a-member errors - so both pre-C++11 modes produce this one shape. Raise the mode and the same file compiles unchanged: at -std=c++11 it compiles and prints 1 2.5.

The header sweep: a partial rescue that changes the error

A missing standard name is sometimes rescued by accident, when another header happens to include the one that declares it. For std::tuple the sweep finds something in between: a partial rescue that changes the error without fixing the program. Each sweep program uses the tuple with one candidate header as its only include, and no other header - a second include would be its own possible rescue and would spoil the measurement. This program, with <string> in that position and still no <tuple>, fails with a different error from the missing-include shape:

C++
#include <string>

int main() {
    std::tuple<int, double> t(1, 2.5);
    return std::get<0>(t) == 1 ? 0 : 1;
}
Terminal
$ g++ -std=c++11 sweep_string.cpp -o sweep_string
sweep_string.cpp: In function 'int main()':
sweep_string.cpp:4:30: error: variable 'std::tuple<int, double> t' has initializer but incomplete type
    4 |     std::tuple<int, double> t(1, 2.5);
      |                              ^

Read what changed. The title error is gone: the compiler no longer says tuple is not a member of std, because in the sweep above the name is declared - a forward declaration of the class template has been pulled in by the candidate header. But a declaration is not a definition: the compiler knows the name and not the type's contents, so it cannot create a variable of that type, and the one error that remains is the incomplete-type error on the variable declaration. Just as telling, std::get does not error in the sweep programs at all - the only error in each one is the incomplete-type error above - so a file in this state can look close to fixed while the tuple still cannot be used. The same program was compiled with each of <iostream>, <vector>, <algorithm>, <array> and <utility> as the only candidate header, at C++11: every one fails with the same single error, variable 'std::tuple<int, double> t' has initializer but incomplete type. So of the six headers probed in place of <tuple>, all six produce this partial rescue and none produces a working program - among the headers probed, the declaration arrives by accident without the definition. That makes the repair the same as for a name with no rescue at all: include <tuple> directly in every file that names std::tuple, and read an incomplete-type error on a tuple variable as this half-rescued state, not as a different fault.

The fix: include <tuple> and compile at C++11 or later

Both halves together - the header included, the mode at C++11 - and the library is fully usable. This program builds a three-element tuple with std::make_tuple, reads the elements back with std::get, and prints the element count through std::tuple_size:

C++
#include <tuple>
#include <iostream>
#include <string>

int main() {
    std::tuple<std::string, int, double> t = std::make_tuple("ada", 36, 1.5);
    std::cout << std::get<0>(t) << " " << std::get<1>(t) << " " << std::get<2>(t) << "\n";
    std::cout << "size " << std::tuple_size<decltype(t)>::value << "\n";
    return 0;
}
Terminal
$ g++ -std=c++11 p4_fix.cpp -o p4_fix
$ ./p4_fix
ada 36 1.5
size 3

Every name that failed before now resolves. std::make_tuple creates the tuple object with its element types defined by the argument types - a string, an int and a double here - and the three std::get calls read the elements back out by index, in order, printing ada 36 1.5. The second line is the count: std::tuple_size on the tuple's type gives the number of elements it holds, 3, matching the three values the tuple was built from. Element access on a tuple is always this index form - std::get<I>(t) - because a tuple has no named members to read, which is the boundary the next section draws. The output is fully determined by the values in the program, so any other output means the program, not the machine, differs.

Neighboring error: a tuple has no .first

Once <tuple> is included and the mode is right, a wrong access form produces a different error on a different subject. A two-element tuple invites the habit from std::pair, whose elements are the members first and second - but std::tuple is a generalization of std::pair, not a pair with more members, and its elements have no names. Asking a tuple for .first fails like this:

C++
#include <tuple>
#include <iostream>

int main() {
    std::tuple<int, double> t(1, 2.5);
    std::cout << t.first << "\n";
    return 0;
}
Terminal
$ g++ -std=c++11 p5_neighbour_no_member.cpp -o p5_neighbour_no_member
p5_neighbour_no_member.cpp: In function 'int main()':
p5_neighbour_no_member.cpp:6:20: error: 'class std::tuple<int, double>' has no member named 'first'
    6 |     std::cout << t.first << "\n";
      |                    ^~~~~

The contrast separates the two errors cleanly. This error names the class - std::tuple<int, double> - and the missing member, which proves the type was found: the include and the mode are already right, and only the access form is wrong, because a tuple's elements are reached by index, not by name. The title error names tuple as not a member of std, because the type was never there to be used. The repair here is to change the access, not the include: std::get<0>(t) reads the element .first was reaching for, and std::get<1>(t) reads the second one - the same calls the fix program above uses throughout.

Neighboring error: std::get past the end of the tuple

The other neighboring fault keeps the right access form and the wrong index. std::get<I> requires the index to be in range - I must be in [0, sizeof...(Types)) - so index 2 on a tuple of two elements does not read anything; it fails at compile time, inside the library headers, like this:

C++
#include <tuple>
#include <iostream>

int main() {
    std::tuple<int, double> t(1, 2.5);
    std::cout << std::get<2>(t) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++11 p6_neighbour_get_index.cpp -o p6_neighbour_get_index
In file included from p6_neighbour_get_index.cpp:1:
/usr/include/c++/13/tuple: In instantiation of 'struct std::tuple_element<2, std::tuple<int, double> >':
/usr/include/c++/13/bits/utility.h:84:11:   required by substitution of 'template<long unsigned int __i, class _Tp> using std::__tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 2; _Tp = std::tuple<int, double>]'
/usr/include/c++/13/tuple:1824:5:   required by substitution of 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Types ...> >&& std::get(const tuple<_Types ...>&&) [with long unsigned int __i = 2; _Elements = {int, double}]'
p6_neighbour_get_index.cpp:6:29:   required from here
/usr/include/c++/13/tuple:1780:25: error: static assertion failed: tuple index must be in range
 1780 |       static_assert(__i < sizeof...(_Types), "tuple index must be in range");
      |                     ~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/tuple:1780:25: note: the comparison reduces to '(2 < 2)'
/usr/include/c++/13/tuple:1782:13: error: no type named 'type' in 'struct std::_Nth_type<2, int, double>'
 1782 |       using type = typename _Nth_type<__i, _Types...>::type;
      |             ^~~~
p6_neighbour_get_index.cpp: In function 'int main()':
p6_neighbour_get_index.cpp:6:29: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Types ...>&) [with long unsigned int __i = 2; _Elements = {int, double}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
    6 |     std::cout << std::get<2>(t) << "\n";
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/13/tuple:1834:5: note: declared here
 1834 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~

Nothing in this outcome says a name is missing - the include and the mode are right, the type was found, and the failure is the index itself. The line to recognize is the static assertion from inside <tuple>: tuple index must be in range, with the note spelling out the arithmetic that failed, (2 < 2) - index 2 against a tuple of 2 elements, whose valid indexes are 0 and 1. The deleted-function error for std::get underneath it is the same refusal stated the other way: the out-of-range overload is the deleted one. The repair is in the call, not the headers: bring the index below the tuple's element count - std::get<0> and std::get<1> are the reads this two-element tuple supports - or, when the index is computed rather than written, check it against std::tuple_size for the tuple's type before the access. When a tuple program fails with a static assertion from inside the library headers, read it as an index fault in the program's own line - the required from here line in the trace points back at it.

Decision summary

  • The first errors are 'tuple' is not a member of 'std' and 'get' is not a member of 'std', with a note under the first saying 'std::tuple' is defined in header '<tuple>'; did you forget to '#include <tuple>'? and no #error above them: the header is missing - add #include <tuple>, exactly as the note says; every later error in the cascade traces to the absent names.
  • The first error is 'tuple' in namespace 'std' does not name a template type, with the same header note under it: the same missing include, read at namespace scope where the name is used as a type - add <tuple> the same way.
  • The first diagnostic is a #error from inside the library headers saying the file requires compiler and library support for the ISO C++ 2011 standard, the file already includes <tuple>, and the note under the title error says 'std::tuple' is only available from C++11 onwards: the language mode is older than C++11 - the compile line shows -std=c++98, -std=c++03 or an equivalent setting; compile at -std=c++11 or later instead of changing code. The not-a-member errors underneath it are the same shape's fallout, and this shape appears at both probed older modes with identical wording.
  • The error is variable 'std::tuple<int, double> t' has initializer but incomplete type, and it is the only error in the program: the file includes some other header in place of <tuple> - in the sweep above, each of <string>, <iostream>, <vector>, <algorithm>, <array> and <utility> produced exactly this state - so the name is declared but not defined; add <tuple> itself. std::get not erroring in this state is part of the shape, not a sign the program is nearly fixed.
  • The error instead names the class, as in 'class std::tuple<int, double>' has no member named 'first': the type was found and the access form is wrong - a tuple's elements have no names; read them with std::get<0>, std::get<1> and so on, as a std::pair's first and second members do not carry over.
  • The failure is a static assertion from inside <tuple>, tuple index must be in range, with a deleted-function error for std::get: the include and mode are right and the index is past the end - keep the index below the tuple's element count, checking a computed index against std::tuple_size for the type.

Checklist

  • The file includes <tuple> itself - not a neighboring header in its place; in the sweep above, each of the six probed headers left the tuple type incomplete, so none of them stands in for <tuple>.
  • The compile line, or the build system's language standard setting, is C++11 or later; a pre-C++11 mode makes the library headers stop with a #error requiring the ISO C++ 2011 standard, and the not-a-member errors follow it.
  • The first diagnostic is read, not just the title error: a #error about the 2011 standard at the top means the mode is too old, the not-a-member error with the "did you forget to #include <tuple>" note under it means the include is missing, and an incomplete-type error standing alone means a probed neighbor declared the name without defining it; the title error by itself cannot tell the first two shapes apart, because both produce it.
  • The first error is read before the cascade: the expected primary-expression and 'was not declared in this scope' errors disappear when the name error at the top is fixed.
  • Elements are read with std::get<I> by index - never .first or .second, which are std::pair members a tuple does not have.
  • Every std::get index is below the tuple's element count - in [0, sizeof...(Types)) - with a computed index checked against std::tuple_size for the tuple's type.
  • The fixed program compiles at C++11, runs, and prints ada 36 1.5 and size 3, in order.
  • 'std::regex' Is Not a Member of 'std' Fix - the same missing-name fault on the regular expression type, with one contrast worth seeing side by side: GCC attaches no note naming the header to add under the std::regex error, where the std::tuple error carries the "did you forget to #include <tuple>" note with the remedy in it - and the same older-mode shape as here, where its header also stops with a #error from inside the library headers first.
  • 'std::string_view' Is Not a Member of 'std' Fix - the same missing-name fault on the string view type: like std::tuple it carries the header note naming the include to add, and its namespace-scope wording is the plainer "does not name a type", where a class template like std::tuple is reported as "does not name a template type".
  • 'std::chrono' Is Not a Member of 'std' Fix - the same fault on the chrono library, and the same older-mode shape as here: at a pre-C++11 mode its header also stops with a #error from inside the library headers before the name errors follow.

Sources

  • cppreference.com, std::tuple — the type at the center of the error: the class template tuple since C++11, a fixed-size collection of heterogeneous values and a generalization of std::pair - with its non-member list giving make_tuple since C++11, creating a tuple object of the type defined by the argument types, and the std::tuple_size<std::tuple> helper specialization since C++11, which obtains the size of a tuple - the operations the fix program uses.
  • cppreference.com, Standard library header (C++11) — what the header declares: the tuple class template, the tuple_size and tuple_element helper templates and their std::tuple specializations, the ignore constant, and the make_tuple, tie, forward_as_tuple, tuple_cat and get function templates, all in namespace std and since C++11 - the declarations a file gets by including <tuple> itself; in the sweep above, no probed neighbor brought the definition in with them.
  • cppreference.com, std::get (std::tuple) — the access the programs use: defined in header <tuple>, the index form of get since C++11, extracting the Ith element from the tuple, with I required to be an integer value in [0, sizeof...(Types)) - the in-range rule the out-of-range neighboring error breaks, and the reason tuple elements are read by index rather than by a member name.

Keep Exploring