#include <bslma_constructionutil.h>
|
template<class TARGET_TYPE , class ALLOCATOR > |
static void | construct (TARGET_TYPE *address, const ALLOCATOR &allocator) |
|
template<class TARGET_TYPE , class ALLOCATOR , class ARG1 , class... ARGS> |
static void | construct (TARGET_TYPE *address, const ALLOCATOR &allocator, ARG1 &argument1, ARGS &&... arguments) |
|
template<class TARGET_TYPE , class ALLOCATOR , class ARG1 , class... ARGS> |
static void | construct (TARGET_TYPE *address, const ALLOCATOR &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(ARG1) argument1, ARGS &&... arguments) |
|
template<class TARGET_TYPE , class ALLOCATOR > |
static void | destructiveMove (TARGET_TYPE *address, const ALLOCATOR &allocator, TARGET_TYPE *original) |
|
This struct
provides a namespace for utility functions that construct elements of (a template parameter) TARGET_TYPE
.
◆ construct() [1/3]
template<class TARGET_TYPE , class ALLOCATOR >
void bslma::ConstructionUtil::construct |
( |
TARGET_TYPE * |
address, |
|
|
const ALLOCATOR & |
allocator |
|
) |
| |
|
inlinestatic |
Create a default-constructed object of (template parameter) TARGET_TYPE
at the specified address
. If allocator
is a bslma
-compatible allocator and TARGET_TYPE
supports bslma
-style allocation, allocator
is passed to the default extended constructor; otherwise, allocator
is ignored. If the constructor throws, the memory at address
is left in an unspecified state. The behavior is undefined unless address
refers to a block that is of sufficient size and properly aligned for objects of TARGET_TYPE
.
◆ construct() [2/3]
template<class TARGET_TYPE , class ALLOCATOR , class ARG1 , class... ARGS>
void bslma::ConstructionUtil::construct |
( |
TARGET_TYPE * |
address, |
|
|
const ALLOCATOR & |
allocator, |
|
|
ARG1 & |
argument1, |
|
|
ARGS &&... |
arguments |
|
) |
| |
|
inlinestatic |
◆ construct() [3/3]
template<class TARGET_TYPE , class ALLOCATOR , class ARG1 , class... ARGS>
void bslma::ConstructionUtil::construct |
( |
TARGET_TYPE * |
address, |
|
|
const ALLOCATOR & |
allocator, |
|
|
BSLS_COMPILERFEATURES_FORWARD_REF(ARG1) |
argument1, |
|
|
ARGS &&... |
arguments |
|
) |
| |
|
inlinestatic |
Create an object of (template parameter) TARGET_TYPE
at the specified address
, constructed by forwarding the specified argument1
and the (variable number of) additional specified arguments
to the corresponding constructor of TARGET_TYPE
. If the specified allocator
is a bslma-compatible allocator and TARGET_TYPE
supports bslma
-style allocation, the allocator is passed to the constructor; otherwise, allocator
is ignored. If the constructor throws, the memory at address
is left in an unspecified state. Note that, in C++03, perfect forwarding is limited such that any lvalue reference in the arguments
parameter pack is const-qualified when forwarded to the TARGET_TYPE
constructor; only argument1
can be forwarded as an unqualified lvalue. The behavior is undefined unless address
refers to a block that is of sufficient size and properly aligned for objects of TARGET_TYPE
.
◆ destructiveMove()
template<class TARGET_TYPE , class ALLOCATOR >
void bslma::ConstructionUtil::destructiveMove |
( |
TARGET_TYPE * |
address, |
|
|
const ALLOCATOR & |
allocator, |
|
|
TARGET_TYPE * |
original |
|
) |
| |
|
inlinestatic |
Create an object of (template parameter) TARGET_TYPE
at the specified address
by moving from the specified original
object, then destroy original
. The specified allocator
is unused (except possibly in precondition checks). The constructed object will have the same allocator (if any) as original
. If bslmf::IsBitwiseMoveable<TARGET_TYPE>::value
is true
, then the entire operation is a simple memcpy
– no constructors or destructors are invoked; otherwise, this method move-constructs an object at address
from the object at original
then invokes the destructor on original
. If the move constructor throws an exception, the memory at address
is left in an uninitialized state and original
is left in a valid but unspecified state. The behavior is undefined if original
uses an allocator other than allocator
to supply memory. Note that if original
points to an object of a type derived from TARGET_TYPE
(i.e., a slicing move) where TARGET_TYPE
has a non-virtual
destructor, then original
will be only partially destroyed.
The documentation for this struct was generated from the following file: