GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::forward_as_tuple(3) C++ Standard Libary std::forward_as_tuple(3)

std::forward_as_tuple - std::forward_as_tuple


Defined in header <tuple>
template< class... Types > (since C++11)
tuple<Types&&...> forward_as_tuple( Types&&... args ) (constexpr since C++14)
noexcept;


Constructs a tuple of references to the arguments in args suitable for forwarding as
an argument to a function. The tuple has rvalue reference data members when rvalues
are used as arguments, and otherwise has lvalue reference data members.


args - zero or more arguments to construct the tuple from


A std::tuple object created as if by
std::tuple<Types&&...>(std::forward<Types>(args)...)


If the arguments are temporaries, forward_as_tuple does not extend their lifetime;
they have to be used before the end of the full expression.

// Run this code


#include <iostream>
#include <map>
#include <tuple>
#include <string>


int main()
{
std::map<int, std::string> m;


m.emplace(std::piecewise_construct,
std::forward_as_tuple(10),
std::forward_as_tuple(20, 'a'));
std::cout << "m[10] = " << m[10] << '\n';


// The following is an error: it produces a
// std::tuple<int&&, char&&> holding two dangling references.
//
// auto t = std::forward_as_tuple(20, 'a');
// m.emplace(std::piecewise_construct, std::forward_as_tuple(10), t);
}


m[10] = aaaaaaaaaaaaaaaaaaaa


make_tuple creates a tuple object of the type defined by the argument types
(C++11) (function template)
tie creates a tuple of lvalue references or unpacks a tuple into individual
(C++11) objects
(function template)
tuple_cat creates a tuple by concatenating any number of tuples
(C++11) (function template)
apply calls a function with a tuple of arguments
(C++17) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.