public member function
<initializer_list>

std::initializer_list::end

const T* end() const noexcept;
constexpr const T* end() const noexcept;
Return iterator to end
Returns a pointer to the past-the-end element in the initializer_list.

Parameters

none

Return Value

A pointer to the position that follows the last element in the initializer_list.

T is the type of the elements in the initializer_list (i.e., the class template parameter).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// initializer_list::begin/end
#include <iostream>          // std::cout
#include <string>            // std::string
#include <sstream>           // std::stringstream
#include <initializer_list>  // std::initializer_list

struct myclass {
  std::string str;
  myclass(std::initializer_list<int> args) {
    std::stringstream ss;
    std::initializer_list<int>::iterator it;  // same as: const int* it
    for ( it=args.begin(); it!=args.end(); ++it) ss << ' ' << *it;
    str = ss.str();
  }
};

int main ()
{
  myclass myobject {10, 20, 30};
  std::cout << "myobject contains:" << myobject.str << '\n';
  return 0;
}

Output:
myobject contains: 10 20 30


Complexity

Constant.

Data races

The object is accessed. All contained elements are constant: Concurrently accessing them is always safe.

Exception safety

No-throw guarantee: this member function never throws exceptions.

See also