- The C Standard Library
- The C Standard Library
- The C++ Standard Library
- C++ Library - Home
- C++ Library - <fstream>
- C++ Library - <iomanip>
- C++ Library - <ios>
- C++ Library - <iosfwd>
- C++ Library - <iostream>
- C++ Library - <istream>
- C++ Library - <ostream>
- C++ Library - <sstream>
- C++ Library - <streambuf>
- C++ Library - <atomic>
- C++ Library - <complex>
- C++ Library - <exception>
- C++ Library - <functional>
- C++ Library - <limits>
- C++ Library - <locale>
- C++ Library - <memory>
- C++ Library - <new>
- C++ Library - <numeric>
- C++ Library - <regex>
- C++ Library - <stdexcept>
- C++ Library - <string>
- C++ Library - <thread>
- C++ Library - <tuple>
- C++ Library - <typeinfo>
- C++ Library - <utility>
- C++ Library - <valarray>
- The C++ STL Library
- C++ Library - <array>
- C++ Library - <bitset>
- C++ Library - <deque>
- C++ Library - <forward_list>
- C++ Library - <list>
- C++ Library - <map>
- C++ Library - <queue>
- C++ Library - <set>
- C++ Library - <stack>
- C++ Library - <unordered_map>
- C++ Library - <unordered_set>
- C++ Library - <vector>
- C++ Library - <algorithm>
- C++ Library - <iterator>
- C++ Programming Resources
- C++ Programming Tutorial
- C++ Useful Resources
- C++ Discussion
C++ Tuple Library - operator=
Description
It is a tuple operator and assigns tpl (or pr) as the new content for the tuple object.
Declaration
Following is the declaration for std::tuple::operator=
C++98
tuple& operator= (const tuple& tpl); tuple& operator= ( tuple&& tpl) noexcept
C++11
tuple& operator= (const tuple& tpl); tuple& operator= ( tuple&& tpl) noexcept
Parameters
tpl − It is a another tuple object with same number of elements.
pr − it has pair of objects.
Return Value
none
Exceptions
No-throw guarantee − this member function never throws exceptions.
Data races
All copied elements are accessed.
Example
In below example for std::tuple::operator=.
#include <iostream> #include <utility> #include <tuple> int main () { std::pair<int,char> mypair (0,' '); std::tuple<int,char> a (10,'x'); std::tuple<long,char> b, c; b = a; c = std::make_tuple (100L,'Y'); a = c; c = std::make_tuple (100,'z'); a = mypair; a = std::make_pair (2,'b'); std::cout << "a contains: " << std::get<0>(a); std::cout << " and " << std::get<1>(a) << '\n'; return 0; }
The output should be like this −
a contains: 2 and b
tuple.htm
Advertisements
To Continue Learning Please Login
Login with Google