c++11 - New Features in C++ - what does this code means -
this question has answer here:
i going thru self learning of std::make_unique functionality found below declaration @ cppreference.com
template< class t, class... args > unique_ptr<t> make_unique( args&&... args );
i not able understand signature of method / function above.
there many "new" features used in declaration:
- templates (
template
keyword; see https://en.wikipedia.org/wiki/template_(c%2b%2b)) - variadic templates (the
...
argument; see https://en.wikipedia.org/wiki/variadic_template) - smart pointers (
unique_ptr
, see https://en.wikipedia.org/wiki/smart_pointer) - rvalue references (
args&&
, see https://en.wikipedia.org/wiki/c%2b%2b11#rvalue_references_and_move_constructors)
basically code means "declare template functions arbitrary number of parameters of type , return unique_ptr specialised given type t". in addition rvalue reference (&&) tells parameters moved instead of copied.
in short: make_unique<type>(v)
same unique_ptr<type>(new type(v))
.
Comments
Post a Comment