Consider this structure:
struct MyStruct
{
int my_number;
std::string my_string;
};
Is it possible to create a std::unique_ptr
using Designated initializers? Like this:
// like this
auto my_struct = std::make_unique<MyStruct>{.my_number = 4, .my_string = "two"};
// not like this
auto my_struct = std::make_unique<MyStruct>(4, "two");
I've managed to create a new object as an argument to unique_ptr
, but find it ugly:
auto my_struct = std::unique_ptr<MyStruct>(new MyStruct{.my_number = 4, .my_string = "two"});