若实参是临时量,则 forward_as_tuple 不延续其生存期;必须在完整表达式结尾前使用它们。 示例运行此代码 #include <iostream> #include #include <string> #include <tuple> int main() { std::map<int, std::string> m; m.emplace(std::piecewise_construct, std::forward_as_tuple(6), std::forward...
Following is the syntax for std::tuple::forward_as_tuple() function. forward_as_tuple(Types&&...args)noexcept; Parameters args− It indicates the list of elements to be forwarded as a tuple object of reference. Explore ourlatest online coursesand learn new skills at your own pace. Enroll...
Constructs a tuple of references to the arguments inargssuitable 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.