make_unique and perfect forwarding

后端 未结 6 1730
南方客
南方客 2020-11-22 10:24

Why is there no std::make_unique function template in the standard C++11 library? I find

std::unique_ptr p(new SomeUs         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 11:07

    Herb Sutter, chair of the C++ standardization committee, writes on his blog:

    That C++11 doesn’t include make_unique is partly an oversight, and it will almost certainly be added in the future.

    He also gives an implementation that is identical with the one given by the OP.

    Edit: std::make_unique now is part of C++14.

提交回复
热议问题