No, but this is what std::generate for.
Instead of specifying a single value copied over the entire target range, std::generate sets the function "generator", which if necessary creates each value.
So maybe something like this:
std::unique_ptr<int> ar[3]; std::generate( std::begin(ar), std::end(ar), []() { return std::make_unique<int>(1); } );
I have not tried it, and I do not know if you need to do this at all to avoid problems related to incompatibility. Hopefully the semantics of displacement are enough.
(Of course, in C ++ 11, you will need your own make_unique function .)
By the way, your .begin() and .end() were wrong (arrays have no member functions), so (thanks to a reminder from songyuanyao) I fixed them.
source share