1 #include <iostream> 2 #include <tuple> 3 using namespace std; 4 5 struct A 6 { 7 std::string _name; 8 size_t _age; 9 10 A(std::string name, size_t age) : _name(name), _age(age) { cout << "name: " << _name << ", age: " << _age << endl; } 11 }; 12 13 int main() 14 { 15 auto param = std::make_tuple("kai", 18); 16 std::make_from_tuple<A>(std::move(param)); 17 18 return 0; 19 }
输出:
name: kai, age: 18