About 429,000 results
Open links in new tab
  1. Advantages of using std::make_unique over new operator

    The difference is that std::make_unique returns an object of type std::unique_ptr and new returns a pointer to the created object. For memory allocation failures, they will both throw.

  2. Why use std::make_unique in C++17? - Stack Overflow

    Dec 20, 2018 · Since then, C++17 has clarified the evaluation order, making Syntax A safe too, so here's my question: is there still a reason to use std::make_unique over std::unique_ptr 's …

  3. Differences between std::make_unique and std::unique_ptr with new

    How would you deal with polymorphism without new? For example, you need a container of entities, the exact type of which is defined at runtime, and use std::unique_ptr rather than raw …

  4. How can I use make_unique with c++11? - Stack Overflow

    Sep 24, 2020 · If you look at the cppreference doc for std::make_unique(), it shows a possible implementation that (with minor tweaks) can be applied to C++11 code. If your code doesn't …

  5. c++ - make_uniqueの利点 - スタック・オーバーフロー

    May 15, 2016 · make_unique を使用するとコンストラクター呼び出しではなくなるので auto 変数が使えます。対して std::unique_ptr はコンストラクター呼び出しなので型名を省略でき …

  6. How does returning std::make_unique<SubClass> work?

    The reason you can return std::make_unique<Derived> from a function declared to return std::unique_ptr<Base> is that there is a conversion from one to the other.

  7. What does std::make_unique_for_overwrite () do vis-a-vis …

    These new functions are different: Original make_XYZ: Always initializes the pointed-to value ("explicit initialization", see § class.expl.init in the standard). New make_XYZ_for_overwrite: …

  8. c++ - std::make_unique<T> vs reset (new T) - Stack Overflow

    Dec 6, 2016 · some_func(std::make_unique<Foo>(), std::make_unique<Foo>()); Now that we are calling a function, the new will be called before the constructor for each parameter in that …

  9. Custom initialize array with std::make_unique - Stack Overflow

    Apr 9, 2018 · Say I would like to create a std::unique_ptr<int[]>, but I would like to initialize the created array to custom values: {1,2,3,4,5}. I can use new and pass the raw pointer to …

  10. c++ - Does assigning make_unique require std::move () to an …

    Jan 18, 2018 · It's not, because in both cases the expression may bind to an rvalue reference. In the first, std::make_unique already returns a pure rvalue. In the second, std::move does a cast …