diff --git a/make_unique.html b/make_unique.html index b649245..7500a87 100644 --- a/make_unique.html +++ b/make_unique.html @@ -1,150 +1,176 @@ - - -
-Introduction
- Synopsis
- Common Requirements
- Free Functions
- History
The header file <boost/make_unique.hpp> provides overloaded
- function template make_unique
for convenient creation of
- unique_ptr
objects.
namespace boost { - template<class U> // U is not array - unique_ptr<U> make_unique(); - - template<class U, class... Args> // U is not array - unique_ptr<U> make_unique(Args&&... args); - - template<class U> // U is not array - unique_ptr<U> make_unique(U&& value); - - template<class U> // U is T[] - unique_ptr<U> make_unique(size_t size); - - template<class U> // U is not array - unique_ptr<U> make_unique_noinit(); - - template<class U> // U is T[] - unique_ptr<U> make_unique_noinit(size_t size); -}-
template<class U> -unique_ptr<U> make_unique(args);-
template<class U> -unique_ptr<U> make_unique_noinit(args);-
--Effects: Allocates memory for an object of type
-U
- (orT[size]
whenU
isT[]
, - wheresize
is determined fromargs
as - specified by the concrete overload). The object is initialized from -args
as specified by the concrete overload. If an - exception is thrown, the functions have no effect.Returns: A
-unique_ptr
instance that stores and - owns the address of the newly constructed object.Postconditions:
-r.get() != 0
, where -r
is the return value.Throws:
-bad_alloc
, or an exception thrown from - the initialization of the object.Remarks:
---When an object of a non-array type
-T
is specified to - be initialized to a valuevalue
, or to -T(list...)
, wherelist...
is a list of - constructor arguments,make_unique
shall perform this - initialization via the expressionnew T(value)
or -new T(list...)
respectively.When an object of type
-T
is specified to be - value-initialized,make_unique
shall perform this - initialization via the expressionnew T()
.When an object of type
-T
is specified to be - default-initialized,make_unique_noinit
shall perform - this initialization via the expressionnew T
.
template<class U, class... Args> -unique_ptr<U> make_unique(Args&&... args);-
--Returns: A unique_ptr to an object of type
-U
, - initialized toU(forward<Args>(args)...)
.Remarks: This overload shall only participate in overload - resolution when
-U
is not an array type.Examples:
---unique_ptr<float> p1 = boost::make_unique<float>();-unique_ptr<point> p2 = boost::make_unique<point>(x, y);-
template<class U> -unique_ptr<U> make_unique(U&& value);-
--Returns: A unique_ptr to an object of type
-U
, - initialized tomove(value)
.Remarks: This overload shall only participate in overload - resolution when
-U
is not an array type.Examples:
---unique_ptr<string> p1 = boost::make_unique<string>({'a', 'b'});-unique_ptr<point> p2 = boost::make_unique<point>({-10, 25});-
template<class U> -unique_ptr<U> make_unique(size_t size);-
--Returns: A unique_ptr to a value-initialized object of type -
-T[size]
.Remarks: This overload shall only participate in overload - resolution when
-U
is of the formT[]
.Examples:
---unique_ptr<double[]> p1 = boost::make_unique<double[]>(4);-unique_ptr<int[][2]> p2 = boost::make_unique<int[][2]>(2);-
template<class U> -unique_ptr<U> make_unique_noinit();-
--Returns: A unique_ptr to a default-initialized object of - type
-U
.Remarks: This overload shall only participate in overload - resolution when
-U
is not an array type.Examples:
---unique_ptr<float> p1 = boost::make_unique_noinit<float>();-unique_ptr<point> p2 = boost::make_unique_noinit<point>();-
template<class U> -unique_ptr<U> make_unique_noinit(size_t size);-
--Returns: A unique_ptr to a default-initialized object of - type
-T[size]
.Remarks: This overload shall only participate in overload - resolution when
-U
is of the formT[]
.Examples:
---unique_ptr<double[]> p1 = boost::make_unique_noinit<double[]>(4);-unique_ptr<int[][2]> p2 = boost::make_unique_noinit<int[][2]>(2);-
January 2014. Glen Fernandes contributed implementations of - make_unique for objects and arrays.
-$Date$
-Copyright 2012-2014 Glen Fernandes. Distributed under the - Boost Software License, Version 1.0. See accompanying file - LICENSE_1_0.txt or copy at - - http://www.boost.org/LICENSE_1_0.txt.
- + + + + +
+The header file <boost/make_unique.hpp> provides overloads of
+function template make_unique
for convenient creation of
+std::unique_ptr
objects.
+
namespace boost {
+
+template<class T>
std::unique_ptr<T>
+make_unique();
+
+
+template<class T, class... Args>
std::unique_ptr<T>
+make_unique(Args&&... args);
+
+
+template<class T>
std::unique_ptr<T>
+make_unique(T&& value);
+
+
+template<class T>
std::unique_ptr<T>
+make_unique(std::size_t size);
+
+
+template<class T>
std::unique_ptr<T>
+make_unique_noinit();
+
+
+template<class T>
std::unique_ptr<T>
+make_unique_noinit(std::size_t size);
+
+}
+template<class T, Args>
+std::unique_ptr<T>
+make_unique(args);
T
(or
+E[size]
when T
is E[]
, where
+size
is determined from args
as specified by
+the concrete overload). The storage is initialized from
+args
as specified by the concrete overload. If an exception
+is thrown, the functions have no effect.std::unique_ptr
instance that stores and owns the
+address of the newly allocated and constructed object.r.get() != 0
, where r
is the return
+value.std::bad_alloc
, or an exception thrown from the
+initialization of the object.value
, or to T(args...)
, where
+args...
is a list of constructor arguments,
+make_unique
shall perform this initialization via the
+expression new T(value)
or new T(args...)
+respectively.T
is specified to be
+value-initialized, make_unique
shall perform this
+initialization via the expression new T()
.T
is specified to be
+default-initialized, make_unique_noinit
shall perform this
+initialization via the expression new T
.template<class T, class... Args>
+std::unique_ptr<T>
+make_unique(Args&&... args);
std::unique_ptr
to an object of type T
,
+initialized to std::forward<Args>(args)...
.T
is not an array type.template<class T>
std::unique_ptr<T>
+make_unique(T&& value);
std::unique_ptr
to an object of type T
,
+initialized to std::move(value)
.T
is not an array type.template<class T>
std::unique_ptr<T>
+make_unique(std::size_t size);
std::unique_ptr
to a value-initialized object of type
+E[size]
.T
is of the form E[]
.template<class T>
std::unique_ptr<T>
+make_unique_noinit();
std::unique_ptr
to a default-initialized object of
+type T
.T
is not an array type.template<class T>
std::unique_ptr<T>
+make_unique_noinit(std::size_t size);
std::unique_ptr
to a default-initialized object of
+type E[size]
.T
is of the form E[]
.