function template
<tuple>
std::tietemplate<class... Types> tuple<Types&...> tie (Types&... args) noexcept;
template<class... Types> constexpr tuple<Types&...> tie (Types&... args) noexcept;
Tie arguments to tuple elements
Constructs a tuple object whose elements are references to the arguments in args, in the same order.This allows a set of objects to act as a tuple, which is especially useful to unpack tuple objects.
The special constant ignore can be used to specify elements of a tuple to be ignored instead of tied to a specific object.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// packing/unpacking tuples
#include <iostream> // std::cout
#include <tuple> // std::tuple, std::make_tuple, std::tie
int main ()
{
int myint;
char mychar;
std::tuple<int,float,char> mytuple;
mytuple = std::make_tuple (10, 2.6, 'a'); // packing values into tuple
std::tie (myint, std::ignore, mychar) = mytuple; // unpacking tuple into variables
std::cout << "myint contains: " << myint << '\n';
std::cout << "mychar contains: " << mychar << '\n';
return 0;
}
myint contains: 10 mychar contains: a
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