In C++20, this will compile:
std::make_unique<point>(1, 2);
due to the new rule allowing initializing aggregates from a parenthesized list of values.
In C++17, you can just do:
std::unique_ptr<point>(new point{1, 2});
That won’t work with make_shared though. So you can also just create a factory (forwarding left as an exercise):
template <typename... Args>
struct braced_init {
braced_init(Args... args) : args(args...) { }
std::tuple<Args...> args;
template <typename T>
operator T() const {
return std::apply([](Args... args){
return T{args...};
}, args);
}
};
std::make_unique<point>(braced_init(1, 2));
In C++14, you’ll have to implement apply and write a factory function for braced_init because there’s no CTAD yet – but these are doable.
Seeing how the general trend appears to prefer braces for initialization
Citation needed. It’s a charged topic – but I definitely disagree with the claim.