8#ifndef INCLUDED_BSLMA_CONSTRUCTIONUTIL
9#define INCLUDED_BSLMA_CONSTRUCTIONUTIL
672#include <bslscm_version.h>
705#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
709# define COMPILING_BSLMA_CONSTRUCTIONUTIL_H
711# undef COMPILING_BSLMA_CONSTRUCTIONUTIL_H
725#if defined(BSLS_PLATFORM_CMP_IBM) && BSLS_PLATFORM_CMP_VERSION < 0x0d01
726 #define BSLMA_CONSTRUCTIONUTIL_XLC_PLACEMENT_NEW_FIX \
727 BSLS_PERFORMANCEHINT_OPTIMIZATION_FENCE
729 #define BSLMA_CONSTRUCTIONUTIL_XLC_PLACEMENT_NEW_FIX
732struct ConstructionUtil_Imp;
761 template <
class TARGET_TYPE,
class ALLOCATOR>
762 static void construct(TARGET_TYPE *address,
const ALLOCATOR& allocator);
764#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
765# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
767 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
768 static void construct(TARGET_TYPE *address,
769 const ALLOCATOR& allocator,
771 ARGS&&... arguments);
789 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
790 static void construct(TARGET_TYPE *address,
791 const ALLOCATOR& allocator,
793 ARGS&&... arguments);
813 template <
class TARGET_TYPE,
class ALLOCATOR>
815 const ALLOCATOR& allocator,
816 TARGET_TYPE *original);
818#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
828 template <
class TARGET_TYPE,
class ALLOCATOR>
829 static TARGET_TYPE make(
const ALLOCATOR& allocator);
831#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
832# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
834 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
835 static TARGET_TYPE make(
const ALLOCATOR& allocator,
837 ARGS&&... arguments);
855 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
856 static TARGET_TYPE make(
const ALLOCATOR& allocator,
858 ARGS&&... arguments);
898 template <
class TARGET_TYPE,
class ALLOCATOR>
900 TARGET_TYPE *address,
901 const ALLOCATOR& allocator,
903 template <
class TARGET_TYPE,
class ALLOCATOR>
905 TARGET_TYPE *address,
906 const ALLOCATOR& allocator,
908 template <
class TARGET_TYPE,
class ALLOCATOR>
910 TARGET_TYPE *address,
911 const ALLOCATOR& allocator,
914#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
915# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
917 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
919 TARGET_TYPE *address,
920 const ALLOCATOR& allocator,
923 ARGS&&... arguments);
924 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
926 TARGET_TYPE *address,
927 const ALLOCATOR& allocator,
930 ARGS&&... arguments);
931 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
933 TARGET_TYPE *address,
934 const ALLOCATOR& allocator,
937 ARGS&&... arguments);
947 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
949 TARGET_TYPE *address,
950 const ALLOCATOR& allocator,
953 ARGS&&... arguments);
954 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
956 TARGET_TYPE *address,
957 const ALLOCATOR& allocator,
960 ARGS&&... arguments);
961 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
963 TARGET_TYPE *address,
964 const ALLOCATOR& allocator,
967 ARGS&&... arguments);
977 template <
class TARGET_TYPE,
class ALLOCATOR>
979 TARGET_TYPE *address,
980 const ALLOCATOR& allocator,
982 TARGET_TYPE *original);
997 template <
class TARGET_TYPE,
class ALLOCATOR>
999 TARGET_TYPE *address,
1000 const ALLOCATOR& allocator,
1002 TARGET_TYPE *original);
1004#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
1010 template <
class TARGET_TYPE,
class ALLOCATOR>
1011 static TARGET_TYPE make(
1012 const ALLOCATOR& allocator,
1014 template <
class TARGET_TYPE,
class ALLOCATOR>
1015 static TARGET_TYPE make(
1016 const ALLOCATOR& allocator,
1018 template <
class TARGET_TYPE,
class ALLOCATOR>
1019 static TARGET_TYPE make(
1020 const ALLOCATOR& allocator,
1023#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1024# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1026 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1027 static TARGET_TYPE make(
1028 const ALLOCATOR& allocator,
1031 ARGS&&... arguments);
1032 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1033 static TARGET_TYPE make(
1034 const ALLOCATOR& allocator,
1037 ARGS&&... arguments);
1038 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1039 static TARGET_TYPE make(
1040 const ALLOCATOR& allocator,
1043 ARGS&&... arguments);
1052 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1053 static TARGET_TYPE make(
1054 const ALLOCATOR& allocator,
1057 ARGS&&... arguments);
1058 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1059 static TARGET_TYPE make(
1060 const ALLOCATOR& allocator,
1063 ARGS&&... arguments);
1064 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1065 static TARGET_TYPE make(
1066 const ALLOCATOR& allocator,
1069 ARGS&&... arguments);
1076 template <
class TARGET_TYPE>
1077 static void *
voidify(TARGET_TYPE *address);
1091template <
class ALLOC>
1092struct ConstructionUtil_IsAllocatorPtr;
1096template <
class ALLOC>
1102template <
class ALLOC>
1158template <
class TARGET_TYPE,
class ALLOCATOR>
1186template <
class TYPE,
1195template <
class TYPE>
1203template <
class TYPE>
1210 template <
class ALLOC>
1216 template <
class ALLOC>
1224template <
class TYPE,
bool IS_BSLMA_AA>
1230 template <
class ALLOC>
1231 static typename TYPE::allocator_type
adapt(
const ALLOC& a) {
return a; }
1240template <
class TARGET_TYPE,
class ALLOCATOR>
1244 const ALLOCATOR& allocator)
1252#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1253# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1254template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1258 const ALLOCATOR& allocator,
1260 ARGS&&... arguments)
1273template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1277 const ALLOCATOR& allocator,
1279 ARGS&&... arguments)
1292template <
class TARGET_TYPE,
class ALLOCATOR>
1296 const ALLOCATOR& allocator,
1297 TARGET_TYPE *original)
1314#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
1319template <
class TARGET_TYPE,
class ALLOCATOR>
1322ConstructionUtil::make(
const ALLOCATOR& allocator)
1327 return Imp::make<TARGET_TYPE>(allocator, Trait());
1330#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1331# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1332template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1335ConstructionUtil::make(
const ALLOCATOR& allocator,
1337 ARGS&&... arguments)
1342 return Imp::make<TARGET_TYPE>(
1350template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1353ConstructionUtil::make(
const ALLOCATOR& allocator,
1355 ARGS&&... arguments)
1360 return Imp::make<TARGET_TYPE>(
1376template <
class TARGET_TYPE,
class ALLOCATOR>
1380 TARGET_TYPE *address,
1381 const ALLOCATOR& allocator,
1385 ::new (
voidify(address)) TARGET_TYPE(bsl::allocator_arg,
1386 AllocUtil::adapt(allocator));
1390template <
class TARGET_TYPE,
class ALLOCATOR>
1394 TARGET_TYPE *address,
1395 const ALLOCATOR& allocator,
1399 ::new (
voidify(address)) TARGET_TYPE(AllocUtil::adapt(allocator));
1403template <
class TARGET_TYPE,
class ALLOCATOR>
1407 TARGET_TYPE *address,
1411 ::new (
voidify(address)) TARGET_TYPE();
1415#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1416# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1417template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1421 TARGET_TYPE *address,
1422 const ALLOCATOR& allocator,
1425 ARGS&&... arguments)
1428 ::new (
voidify(address)) TARGET_TYPE(
1430 AllocUtil::adapt(allocator),
1436template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1440 TARGET_TYPE *address,
1441 const ALLOCATOR& allocator,
1444 ARGS&&... arguments)
1447 ::new (
voidify(address)) TARGET_TYPE(
1450 AllocUtil::adapt(allocator));
1454template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1458 TARGET_TYPE *address,
1462 ARGS&&... arguments)
1464 ::new (
voidify(address)) TARGET_TYPE(
1471template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1475 TARGET_TYPE *address,
1476 const ALLOCATOR& allocator,
1479 ARGS&&... arguments)
1482 ::new (
voidify(address)) TARGET_TYPE(
1484 AllocUtil::adapt(allocator),
1490template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1494 TARGET_TYPE *address,
1495 const ALLOCATOR& allocator,
1498 ARGS&&... arguments)
1501 ::new (
voidify(address)) TARGET_TYPE(
1504 AllocUtil::adapt(allocator));
1508template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1512 TARGET_TYPE *address,
1516 ARGS&&... arguments)
1518 ::new (
voidify(address)) TARGET_TYPE(
1525template <
class TARGET_TYPE,
class ALLOCATOR>
1529 TARGET_TYPE *address,
1532 TARGET_TYPE *original)
1536 ::new (
voidify(address)) TARGET_TYPE(*original);
1542 memcpy(
voidify(address), original,
sizeof *original);
1546template <
class TARGET_TYPE,
class ALLOCATOR>
1550 TARGET_TYPE *address,
1551 const ALLOCATOR& allocator,
1553 TARGET_TYPE *original)
1564 DestructionUtil::destroy(original);
1567#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
1572template <
class TARGET_TYPE,
class ALLOCATOR>
1575ConstructionUtil_Imp::make(
1576 const ALLOCATOR& allocator,
1580 return TARGET_TYPE(bsl::allocator_arg, AllocUtil::adapt(allocator));
1583template <
class TARGET_TYPE,
class ALLOCATOR>
1586ConstructionUtil_Imp::make(
1587 const ALLOCATOR& allocator,
1590 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1591 return TARGET_TYPE(AllocUtil::adapt(allocator));
1594template <
class TARGET_TYPE,
class ALLOCATOR>
1597ConstructionUtil_Imp::make(
1601 return TARGET_TYPE();
1604#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1605# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1606template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1609ConstructionUtil_Imp::make(
1610 const ALLOCATOR& allocator,
1613 ARGS&&... arguments)
1615 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1618 AllocUtil::adapt(allocator),
1623template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1626ConstructionUtil_Imp::make(
1627 const ALLOCATOR& allocator,
1630 ARGS&&... arguments)
1632 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1636 AllocUtil::adapt(allocator));
1639template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1642ConstructionUtil_Imp::make(
1646 ARGS&&... arguments)
1654template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1657ConstructionUtil_Imp::make(
1658 const ALLOCATOR& allocator,
1661 ARGS&&... arguments)
1663 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1666 AllocUtil::adapt(allocator),
1671template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1674ConstructionUtil_Imp::make(
1675 const ALLOCATOR& allocator,
1678 ARGS&&... arguments)
1680 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1684 AllocUtil::adapt(allocator));
1687template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1690ConstructionUtil_Imp::make(
1694 ARGS&&... arguments)
1705template <
class TARGET_TYPE>
1709 return static_cast<void *
>(
#define BSLMA_CONSTRUCTIONUTIL_XLC_PLACEMENT_NEW_FIX
Definition bslma_constructionutil.h:729
Definition bslma_allocator.h:457
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68
Definition bslmf_integralconstant.h:244
Definition bslmf_isclass.h:163
Definition bslmf_isconvertible.h:867
Definition bslmf_isfundamental.h:329
Definition bslmf_ispointer.h:138
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126
Definition bslmf_usesallocator.h:165
static bslma::Allocator * adapt(const ALLOC &a)
Definition bslma_constructionutil.h:1211
static bslma::Allocator * adapt(ALLOC *const &alloc_p)
Definition bslma_constructionutil.h:1217
static TYPE::allocator_type adapt(const ALLOC &a)
Definition bslma_constructionutil.h:1231
Definition bslma_constructionutil.h:1189
Definition bslma_constructionutil.h:1159
bsl::integral_constant< int, value > type
Definition bslma_constructionutil.h:1178
@ value
Definition bslma_constructionutil.h:1168
Definition bslma_constructionutil.h:874
static void destructiveMove(TARGET_TYPE *address, const ALLOCATOR &allocator, bsl::integral_constant< int, e_BITWISE_MOVABLE_TRAITS >, TARGET_TYPE *original)
Definition bslma_constructionutil.h:1528
static void * voidify(TARGET_TYPE *address)
Definition bslma_constructionutil.h:1707
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator, bsl::integral_constant< int, e_USES_ALLOCATOR_ARG_T_TRAITS >)
Definition bslma_constructionutil.h:1379
@ e_NIL_TRAITS
Definition bslma_constructionutil.h:884
@ e_BITWISE_MOVABLE_TRAITS
Definition bslma_constructionutil.h:885
@ e_USES_ALLOCATOR_ARG_T_TRAITS
Definition bslma_constructionutil.h:887
@ e_USES_ALLOCATOR_TRAITS
Definition bslma_constructionutil.h:886
Definition bslma_constructionutil.h:1097
Definition bslma_constructionutil.h:740
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
static void destructiveMove(TARGET_TYPE *address, const ALLOCATOR &allocator, TARGET_TYPE *original)
Definition bslma_constructionutil.h:1295
Definition bslma_hasallocatortype.h:175
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_isbitwisemoveable.h:718
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
Definition bslmf_usesallocatorargt.h:100