A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/tuple/tuple/ below:

class template

<tuple>

std::tuple
template <class... Types> class tuple;

Tuple

A tuple is an object capable to hold a collection of elements. Each element can be of a different type.

Template parameters
Types...
A list of types used for the elements, in the same order as they are going to be ordered in the tuple.

Member types none.

Member functions
(constructor)
Construct tuple (public member function)
tuple::operator=
Assign content (public member function)
tuple::swap
Swap content (public member function)

Non-member function overloads
relational operators (tuple)
Relational operators for tuple (function template)
swap (tuple)
Exchanges the contents of two tuples (function template)
get (tuple)
Get element (function template)

Non-member class specializations
uses_allocator<tuple>
Uses allocator for tuple (class template)

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// tuple example
#include <iostream>     // std::cout
#include <tuple>        // std::tuple, std::get, std::tie, std::ignore

int main ()
{
  std::tuple<int,char> foo (10,'x');
  auto bar = std::make_tuple ("test", 3.1, 14, 'y');

  std::get<2>(bar) = 100;                                    // access element

  int myint; char mychar;

  std::tie (myint, mychar) = foo;                            // unpack elements
  std::tie (std::ignore, std::ignore, myint, mychar) = bar;  // unpack (with ignore)

  mychar = std::get<3>(bar);

  std::get<0>(foo) = std::get<2>(bar);
  std::get<1>(foo) = mychar;

  std::cout << "foo contains: ";
  std::cout << std::get<0>(foo) << ' ';
  std::cout << std::get<1>(foo) << '\n';

  return 0;
}
Output:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4