C++

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

std::iota lives in one header, <numeric> - not <algorithm>, where its fill-and-sort neighbors live - and in the sweep probed here no other header pulls it in on the side, so this error does not hide: the textbook file that fills a vector and prints it gets it in full, exactly like the lean file whose only include is <type_traits>. This guide pins down when the error appears, which probed headers do and do not cause it, and the one include that fixes it by specification.

Written November 30, 2026 · Tested with GCC 13.3.0 · 11 min read

By the end of this guide
  • The error: the include is missing
  • The textbook version fails too - neither textbook header rescues it
  • Neighboring headers: none of the probed ones rescue it
  • The fix

Written November 30, 2026

Tested with GCC 13.3.0

What this guide is

std::iota is a function template defined in the header <numeric>. It fills the range [first, last) with sequentially increasing values, starting with the given value and repeatedly applying ++value to it.

Because the template lives in one specific header, 'iota' is not a member of 'std' has one common cause:

  • The #include <numeric> line is missing. For this error GCC prints no note naming <numeric> and, in the contexts probed here, no suggestion at all, so the fix has to come from knowing the name's home, not from reading a note.

Two traps surround this name. The first is the header guess: std::iota fills a range, so it looks like a sibling of std::fill and std::sort - but those live in <algorithm>, and <algorithm> does not declare std::iota; a file whose only include is <algorithm> gets this same error. The second trap is the opposite of the usual one: for many names a missing include stays hidden because a common header pulls the name in transitively, but in the sweep probed here no header rescues std::iota at all - not <vector>, not <string>, not <iostream>. The textbook version fails alongside the lean one. Each case is separated below.

The error: the include is missing

This program fills the array {0, 0, 0} with increasing values starting at 10 using std::iota, but includes only <type_traits>:

C++
#include <type_traits>
int main() {
    int a[] = {0, 0, 0};
    std::iota(a, a + 3, 10);
    return a[0] == 10 && a[2] == 12 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 a_type_traits.cpp -o a_prog
a_type_traits.cpp: In function 'int main()':
a_type_traits.cpp:4:10: error: 'iota' is not a member of 'std'
    4 |     std::iota(a, a + 3, 10);
      |          ^~~~

That is the whole output: one error, no note, no suggestion. The same program with no include at all fails the same way:

C++
int main() {
    int a[] = {0, 0, 0};
    std::iota(a, a + 3, 10);
    return a[0] == 10 && a[2] == 12 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 n_none.cpp -o n_none_prog
n_none.cpp: In function 'int main()':
n_none.cpp:3:10: error: 'iota' is not a member of 'std'
    3 |     std::iota(a, a + 3, 10);
      |          ^~~~

The textbook version fails too - neither textbook header rescues it

The version most often written first - fill a vector with increasing values and print the elements with std::cout - fails without <numeric>:

C++
#include <iostream>
#include <vector>
int main() {
    std::vector<int> v(3);
    std::iota(v.begin(), v.end(), 10);
    for (int x : v) std::cout << x << " ";
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 t_textbook.cpp -o t_textbook_prog
t_textbook.cpp: In function 'int main()':
t_textbook.cpp:5:10: error: 'iota' is not a member of 'std'
    5 |     std::iota(v.begin(), v.end(), 10);
      |          ^~~~

That is the same error the lean file gets. Neither <vector> nor <iostream> pulls the name in on this library version, alone or together, so neither of those common headers hides the error - in the sweep probed here, the missing <numeric> shows itself in the first file that uses the name. No header except <numeric> is required to declare std::iota, and a program that uses std::iota includes <numeric> rather than hoping for a rescue that, in the sweep probed here, never comes.

Neighboring headers: none of the probed ones rescue it

In a sweep where each header below was compiled as the only header in a program that fills the array {0, 0, 0} with increasing values starting at 10, every probed header fails with the plain is not a member of 'std' error, with no note and no suggestion:

  • <type_traits>
  • <utility>
  • <algorithm>
  • <limits>
  • <mutex>
  • <optional>
  • <cstring>
  • <vector>
  • <string>
  • <iostream>
  • <functional>
  • <array>
  • <memory>

A file with no include at all fails the same way. Only <numeric> itself compiles the program - it is the one header in the sweep that declares the name.

Those outcomes are properties of this library version, not rules of the language - no header except <numeric> is required to declare std::iota, and another library could pull it into one of these headers. What the sweep rules out is relying on it here.

This program includes only <utility>:

C++
#include <utility>
int main() {
    int a[] = {0, 0, 0};
    std::iota(a, a + 3, 10);
    return a[0] == 10 && a[2] == 12 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 s_utility.cpp -o s_utility_prog
s_utility.cpp: In function 'int main()':
s_utility.cpp:4:10: error: 'iota' is not a member of 'std'
    4 |     std::iota(a, a + 3, 10);
      |          ^~~~

And this one includes only <algorithm> - the header that declares the fill, search, and sort algorithms this name is so often grouped with, which still does not declare this one:

C++
#include <algorithm>
int main() {
    int a[] = {0, 0, 0};
    std::iota(a, a + 3, 10);
    return a[0] == 10 && a[2] == 12 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 s_algorithm.cpp -o s_algorithm_prog
s_algorithm.cpp: In function 'int main()':
s_algorithm.cpp:4:10: error: 'iota' is not a member of 'std'
    4 |     std::iota(a, a + 3, 10);
      |          ^~~~

The fix

Add the header:

C++
#include <iostream>
#include <numeric>
int main() {
    int a[] = {0, 0, 0};
    std::iota(a, a + 3, 10);
    for (int x : a) std::cout << x << " ";
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 h_fixed.cpp -o h_prog
$ ./h_prog
10 11 12

One include, <numeric>, declares the template. std::iota(a, a + 3, 10) writes 10 to the first element and ++value - 11, then 12 - to each next one, so the program prints 10 11 12.

The neighboring names: the whole header family fails too

The other names declared by <numeric> fail with the same shape of error in the same lean context. std::reduce - the function template in the same header that reduces a range to a single value - gets its own error, again with no header note and no suggestion:

C++
#include <type_traits>
int main() {
    int a[] = {1, 2, 3};
    auto s = std::reduce(a, a + 3);
    return s == 6 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 b_reduce.cpp -o b_prog
b_reduce.cpp: In function 'int main()':
b_reduce.cpp:4:19: error: 'reduce' is not a member of 'std'
    4 |     auto s = std::reduce(a, a + 3);
      |                   ^~~~~~

And std::inner_product, the function template in the same header that sums the pairwise products of two ranges, fails the same way:

C++
#include <type_traits>
int main() {
    int a[] = {1, 2, 3};
    int b[] = {4, 5, 6};
    auto s = std::inner_product(a, a + 3, b, 0);
    return s == 32 ? 0 : 1;
}
Terminal
$ g++ -std=c++20 c_inner_product.cpp -o c_prog
c_inner_product.cpp: In function 'int main()':
c_inner_product.cpp:5:19: error: 'inner_product' is not a member of 'std'
    5 |     auto s = std::inner_product(a, a + 3, b, 0);
      |                   ^~~~~~~~~~~~~

std::accumulate, the summing function in the same header, fails with this same shape of error when <numeric> is missing - it has its own guide, linked below, so it is not re-derived here. One added include declares every one of these names: the sequence fill, the reduce, the inner product, and the sum.

The neighboring names, fixed

With <numeric> added, std::iota works on more than a plain array of int. The vector of four elements prints as 5 6 7 8 after the fill starting at 5, and the character array becomes abcd - std::iota applies ++ to the starting value 'a', so each next element holds the next character:

C++
#include <iostream>
#include <numeric>
#include <vector>
int main() {
    std::vector<int> v(4);
    std::iota(v.begin(), v.end(), 5);
    for (int x : v) std::cout << x << " ";
    std::cout << "\n";
    char c[] = {0, 0, 0, 0};
    std::iota(c, c + 4, 'a');
    for (char ch : c) std::cout << ch;
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 i_vector_chars.cpp -o i_prog
$ ./i_prog
5 6 7 8
abcd

The starting value only needs a working ++: this type's operator++ steps its member by ten, so filling three elements starting from Step{1} prints 1 11 21:

C++
#include <iostream>
#include <numeric>
struct Step {
    int v;
    Step& operator++() { v += 10; return *this; }
};
int main() {
    Step s[3] = {{1}, {0}, {0}};
    std::iota(s, s + 3, Step{1});
    for (const Step& x : s) std::cout << x.v << " ";
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 j_custom.cpp -o j_prog
$ ./j_prog
1 11 21

And the neighboring names run under the same added include: std::reduce over {1, 2, 3} prints 6, and std::inner_product of {1, 2, 3} with {4, 5, 6} starting from 0 prints 32:

C++
#include <iostream>
#include <numeric>
int main() {
    int a[] = {1, 2, 3};
    int b[] = {4, 5, 6};
    std::cout << std::reduce(a, a + 3) << " " << std::inner_product(a, a + 3, b, 0) << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 k_neighbors_fixed.cpp -o k_prog
$ ./k_prog
6 32

A different wording: the name without its qualifier

Including <numeric> is not the only half of the name. This program includes the header but drops the std:: qualifier:

C++
#include <iostream>
#include <numeric>
int main() {
    int a[] = {0, 0, 0};
    iota(a, a + 3, 10);
    for (int x : a) std::cout << x << " ";
    std::cout << "\n";
    return 0;
}
Terminal
$ g++ -std=c++20 g_unqualified.cpp -o g_prog
g_unqualified.cpp: In function 'int main()':
g_unqualified.cpp:5:5: error: 'iota' was not declared in this scope; did you mean 'std::iota'?
    5 |     iota(a, a + 3, 10);
      |     ^~~~
      |     std::iota
In file included from /usr/include/c++/13/numeric:62,
                 from g_unqualified.cpp:2:
/usr/include/c++/13/bits/stl_numeric.h:88:5: note: 'std::iota' declared here
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~

That wording - was not declared in this scope - is a different defect with a different fix: the header is present, the qualifier is not. Qualify the name as std::iota; adding includes does not bring the name out of namespace std. Here the suggestion names the right function outright - did you mean 'std::iota'?, with the note pointing at the declaration the <numeric> include brought in - so this wording, unlike the missing-include error above, tells the reader exactly what to change.

The exact rule

  • std::iota is declared by #include <numeric>, and nowhere else by rule. In the sweep probed here, <type_traits>, <utility>, <algorithm>, <limits>, <mutex>, <optional>, <cstring>, <vector>, <string>, <iostream>, <functional>, <array>, and <memory> do not declare it, and neither does a file with no include at all.
  • 'iota' is not a member of 'std' means the <numeric> include is missing - and, in the contexts probed here, GCC prints no note naming <numeric> and no suggestion under it.
  • In the sweep probed here, no probed header rescues std::iota transitively: a file whose only include is any one of the thirteen headers above fails the call, and the textbook file with <vector> and <iostream> together fails it too. That is this library version's behavior, not a guarantee - no header is required to leave std::iota out, either.
  • std::iota is not declared by <algorithm>: the fill-and-sort header that declares its look-alike neighbors std::fill and std::sort leaves this name out, in the program shown here and in the sweep.
  • std::reduce and std::inner_product are declared by the same #include <numeric>: in the programs shown here, which include only <type_traits> beside the use, each gets its own is not a member of 'std' error when that include is missing, with no header note and no suggestion.
  • 'iota' was not declared in this scope for an unqualified iota use is a different defect: qualify the name as std::iota - the include alone does not bring the name out of namespace std.

The fixes, ranked

  • First, check the include list of the file that names std::iota. If <numeric> is not there, add it - that is the fix in the common case.
  • Second, do not substitute <algorithm> for it. std::iota fills a range, but it is a numeric algorithm, not an <algorithm> one - in the sweep here the <algorithm>-only file fails with the same error.
  • Third, do not wait for a note naming the header. For this error, in the contexts probed here, GCC prints none - take the fix from the name's home header, <numeric>.
  • Fourth, if the error says was not declared in this scope instead, fix the name's qualifier to std::iota as well - there GCC does suggest the qualified name.
  • Fifth, if the failing name is a neighboring one - reduce, inner_product, or accumulate - the same added include fixes it: every one of those names shares the header, and none of them gets a header note in the programs here either.

Which fix for which cause

  • #include <numeric> missing, std::iota used in a file whose only include is any of <type_traits>, <utility>, <algorithm>, <limits>, <mutex>, <optional>, <cstring>, <vector>, <string>, <iostream>, <functional>, <array>, or <memory>, or that includes nothing: the message is 'iota' is not a member of 'std', with no header note and no suggestion - add #include <numeric>.
  • std::iota used in a textbook file with <vector> and <iostream> included: the same message - neither header rescues the name on this library version, so add #include <numeric> there too.
  • std::reduce or std::inner_product used without <numeric> in the lean context: the message names that name, with no header note - add #include <numeric>.
  • iota used without the std:: qualifier, <numeric> included: the message is 'iota' was not declared in this scope, with a suggestion naming std::iota - qualify the name as std::iota.

Checklist

  • Check the include list of the file that names the fill, not just the project. The include must be in that file, or in a header that file includes directly by design.
  • Do not wait for a note naming the header. For this error, in the contexts probed here, GCC prints none - take the fix from the name's home header, <numeric>, instead.
  • Do not guess <algorithm> from the name's job. std::iota fills a range like std::fill does, but the two names live in different headers - <numeric> for iota, <algorithm> for fill.
  • Do not be reassured or alarmed by the file's size: in the sweep here the textbook file fails exactly like the lean one, because no probed header rescues this name - the include belongs in every file that uses it.
  • One header per name the file uses: std::vector comes from <vector> and std::cout from <iostream>, even in a program whose subject is the fill - and std::iota comes from <numeric> in return.
  • After the fix, confirm the program runs, not just that it compiles: the fixed programs here print 10 11 12 for the filled array, 5 6 7 8 and abcd for the vector and the character array, 1 11 21 for the custom stepped type, and 6 32 for the reduced sum and the inner product.
  • 'std::accumulate' Is Not a Member of 'std' Fix - the same missing-include shape for the summing function in the same header, <numeric>; the one include added there is the one added here.
  • 'std::fill' Is Not a Member of 'std' Fix - the contrasting case: std::fill fills a range with one repeated value where std::iota fills it with increasing ones, std::fill lives in <algorithm> where std::iota does not, and many common headers rescue std::fill where none of the probed headers rescue std::iota.

Sources

  • cppreference, std::iota — for std::iota being a function template defined in <numeric> that fills the range [first, last) with sequentially increasing values, starting with the given value and repeatedly evaluating ++value, with exactly last - first increments and assignments.
  • cppreference, Standard library header <numeric> — for <numeric> being the header that declares the std::iota, std::accumulate, std::inner_product, and std::reduce function templates.
  • cppreference, std::reduce — for std::reduce being a function template defined in <numeric> that reduces a range to a single value.
  • cppreference, std::inner_product — for std::inner_product being a function template defined in <numeric> that computes the sum of the pairwise products of two ranges, accumulated onto an initial value.

Keep Exploring