8#ifndef INCLUDED_BSLMA_CONSTRUCTIONUTIL
9#define INCLUDED_BSLMA_CONSTRUCTIONUTIL
672#include <bslscm_version.h>
700#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
705#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
711# define COMPILING_BSLMA_CONSTRUCTIONUTIL_H
713# undef COMPILING_BSLMA_CONSTRUCTIONUTIL_H
721struct ConstructionUtil_Imp;
753 template <
class TARGET_TYPE,
class ALLOCATOR>
754 static void construct(TARGET_TYPE *address,
const ALLOCATOR& allocator);
756#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
757# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
759 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
760 static void construct(TARGET_TYPE *address,
761 const ALLOCATOR& allocator,
763 ARGS&&... arguments);
783 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
784 static void construct(TARGET_TYPE *address,
785 const ALLOCATOR& allocator,
787 ARGS&&... arguments);
809 template <
class TARGET_TYPE,
class ALLOCATOR>
811 const ALLOCATOR& allocator,
812 TARGET_TYPE *original);
814#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
825 template <
class TARGET_TYPE,
class ALLOCATOR>
826 static TARGET_TYPE make(
const ALLOCATOR& allocator);
828#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
829# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
831 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
832 static TARGET_TYPE make(
const ALLOCATOR& allocator,
834 ARGS&&... arguments);
854 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
855 static TARGET_TYPE make(
const ALLOCATOR& allocator,
857 ARGS&&... arguments);
899 template <
class TARGET_TYPE,
class ALLOCATOR>
901 TARGET_TYPE *address,
902 const ALLOCATOR& allocator,
904 template <
class TARGET_TYPE,
class ALLOCATOR>
906 TARGET_TYPE *address,
907 const ALLOCATOR& allocator,
909 template <
class TARGET_TYPE,
class ALLOCATOR>
911 TARGET_TYPE *address,
912 const ALLOCATOR& allocator,
915#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
916# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
918 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
920 TARGET_TYPE *address,
921 const ALLOCATOR& allocator,
924 ARGS&&... arguments);
925 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
927 TARGET_TYPE *address,
928 const ALLOCATOR& allocator,
931 ARGS&&... arguments);
932 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
934 TARGET_TYPE *address,
935 const ALLOCATOR& allocator,
938 ARGS&&... arguments);
948 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
950 TARGET_TYPE *address,
951 const ALLOCATOR& allocator,
954 ARGS&&... arguments);
955 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
957 TARGET_TYPE *address,
958 const ALLOCATOR& allocator,
961 ARGS&&... arguments);
962 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
964 TARGET_TYPE *address,
965 const ALLOCATOR& allocator,
968 ARGS&&... arguments);
979 template <
class TARGET_TYPE,
class ALLOCATOR>
981 TARGET_TYPE *address,
982 const ALLOCATOR& allocator,
984 TARGET_TYPE *original);
1001 template <
class TARGET_TYPE,
class ALLOCATOR>
1003 TARGET_TYPE *address,
1004 const ALLOCATOR& allocator,
1006 TARGET_TYPE *original);
1008#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
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,
1022 template <
class TARGET_TYPE,
class ALLOCATOR>
1023 static TARGET_TYPE make(
1024 const ALLOCATOR& allocator,
1027#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1028# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1030 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1031 static TARGET_TYPE make(
1032 const ALLOCATOR& allocator,
1035 ARGS&&... arguments);
1036 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1037 static TARGET_TYPE make(
1038 const ALLOCATOR& allocator,
1041 ARGS&&... arguments);
1042 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1043 static TARGET_TYPE make(
1044 const ALLOCATOR& allocator,
1047 ARGS&&... arguments);
1056 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1057 static TARGET_TYPE make(
1058 const ALLOCATOR& allocator,
1061 ARGS&&... arguments);
1062 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1063 static TARGET_TYPE make(
1064 const ALLOCATOR& allocator,
1067 ARGS&&... arguments);
1068 template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1069 static TARGET_TYPE make(
1070 const ALLOCATOR& allocator,
1073 ARGS&&... arguments);
1090template <
class ALLOC>
1091struct ConstructionUtil_IsAllocatorPtr;
1095template <
class ALLOC>
1101template <
class ALLOC>
1159template <
class TARGET_TYPE,
class ALLOCATOR>
1187template <
class TYPE,
1196template <
class TYPE>
1204template <
class TYPE>
1211 template <
class ALLOC>
1217 template <
class ALLOC>
1225template <
class TYPE,
bool IS_BSLMA_AA>
1231 template <
class ALLOC>
1232 static typename TYPE::allocator_type
adapt(
const ALLOC& a) {
return a; }
1241template <
class TARGET_TYPE,
class ALLOCATOR>
1245 const ALLOCATOR& allocator)
1253#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1254# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1255template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1259 const ALLOCATOR& allocator,
1261 ARGS&&... arguments)
1274template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1278 const ALLOCATOR& allocator,
1280 ARGS&&... arguments)
1293template <
class TARGET_TYPE,
class ALLOCATOR>
1297 const ALLOCATOR& allocator,
1298 TARGET_TYPE *original)
1315#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
1320template <
class TARGET_TYPE,
class ALLOCATOR>
1323ConstructionUtil::make(
const ALLOCATOR& allocator)
1328 return Imp::make<TARGET_TYPE>(allocator, Trait());
1331#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1332# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1333template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1336ConstructionUtil::make(
const ALLOCATOR& allocator,
1338 ARGS&&... arguments)
1343 return Imp::make<TARGET_TYPE>(
1351template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1354ConstructionUtil::make(
const ALLOCATOR& allocator,
1356 ARGS&&... arguments)
1361 return Imp::make<TARGET_TYPE>(
1377template <
class TARGET_TYPE,
class ALLOCATOR>
1381 TARGET_TYPE *address,
1382 const ALLOCATOR& allocator,
1388 AllocUtil::adapt(allocator));
1391template <
class TARGET_TYPE,
class ALLOCATOR>
1395 TARGET_TYPE *address,
1396 const ALLOCATOR& allocator,
1401 AllocUtil::adapt(allocator));
1404template <
class TARGET_TYPE,
class ALLOCATOR>
1408 TARGET_TYPE *address,
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)
1430 AllocUtil::adapt(allocator),
1435template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1439 TARGET_TYPE *address,
1440 const ALLOCATOR& allocator,
1443 ARGS&&... arguments)
1449 AllocUtil::adapt(allocator));
1452template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1456 TARGET_TYPE *address,
1460 ARGS&&... arguments)
1468template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1472 TARGET_TYPE *address,
1473 const ALLOCATOR& allocator,
1476 ARGS&&... arguments)
1481 AllocUtil::adapt(allocator),
1486template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1490 TARGET_TYPE *address,
1491 const ALLOCATOR& allocator,
1494 ARGS&&... arguments)
1500 AllocUtil::adapt(allocator));
1503template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1507 TARGET_TYPE *address,
1511 ARGS&&... arguments)
1519template <
class TARGET_TYPE,
class ALLOCATOR>
1523 TARGET_TYPE *address,
1526 TARGET_TYPE *original)
1539template <
class TARGET_TYPE,
class ALLOCATOR>
1543 TARGET_TYPE *address,
1544 const ALLOCATOR& allocator,
1546 TARGET_TYPE *original)
1557 DestructionUtil::destroy(original);
1560#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
1565template <
class TARGET_TYPE,
class ALLOCATOR>
1568ConstructionUtil_Imp::make(
1569 const ALLOCATOR& allocator,
1573 return TARGET_TYPE(bsl::allocator_arg, AllocUtil::adapt(allocator));
1576template <
class TARGET_TYPE,
class ALLOCATOR>
1579ConstructionUtil_Imp::make(
1580 const ALLOCATOR& allocator,
1583 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1584 return TARGET_TYPE(AllocUtil::adapt(allocator));
1587template <
class TARGET_TYPE,
class ALLOCATOR>
1590ConstructionUtil_Imp::make(
1594 return TARGET_TYPE();
1597#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1598# ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1599template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1602ConstructionUtil_Imp::make(
1603 const ALLOCATOR& allocator,
1606 ARGS&&... arguments)
1608 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1611 AllocUtil::adapt(allocator),
1616template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1619ConstructionUtil_Imp::make(
1620 const ALLOCATOR& allocator,
1623 ARGS&&... arguments)
1625 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1629 AllocUtil::adapt(allocator));
1632template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1635ConstructionUtil_Imp::make(
1639 ARGS&&... arguments)
1647template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1650ConstructionUtil_Imp::make(
1651 const ALLOCATOR& allocator,
1654 ARGS&&... arguments)
1656 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1659 AllocUtil::adapt(allocator),
1664template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1667ConstructionUtil_Imp::make(
1668 const ALLOCATOR& allocator,
1671 ARGS&&... arguments)
1673 typedef ConstructionUtil_AllocAdaptorUtil<TARGET_TYPE> AllocUtil;
1677 AllocUtil::adapt(allocator));
1680template <
class TARGET_TYPE,
class ALLOCATOR,
class ARG1,
class... ARGS>
1683ConstructionUtil_Imp::make(
1687 ARGS&&... arguments)
Definition bslma_allocator.h:545
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition baljsn_encoder_testtypes.h:76
Definition bslmf_integralconstant.h:261
Definition bslmf_isclass.h:164
Definition bslmf_isconvertible.h:875
Definition bslmf_isfundamental.h:330
Definition bslmf_ispointer.h:138
Definition bslmf_usesallocator.h:165
static bslma::Allocator * adapt(const ALLOC &a)
Definition bslma_constructionutil.h:1212
static bslma::Allocator * adapt(ALLOC *const &alloc_p)
Definition bslma_constructionutil.h:1218
static TYPE::allocator_type adapt(const ALLOC &a)
Definition bslma_constructionutil.h:1232
Definition bslma_constructionutil.h:1190
Definition bslma_constructionutil.h:1160
@ value
Definition bslma_constructionutil.h:1169
bsl::integral_constant< int, value > type
Definition bslma_constructionutil.h:1179
Definition bslma_constructionutil.h:875
static void destructiveMove(TARGET_TYPE *address, const ALLOCATOR &allocator, bsl::integral_constant< int, e_BITWISE_MOVABLE_TRAITS >, TARGET_TYPE *original)
Definition bslma_constructionutil.h:1522
@ e_NIL_TRAITS
Definition bslma_constructionutil.h:885
@ e_BITWISE_MOVABLE_TRAITS
Definition bslma_constructionutil.h:886
@ e_USES_ALLOCATOR_ARG_T_TRAITS
Definition bslma_constructionutil.h:888
@ e_USES_ALLOCATOR_TRAITS
Definition bslma_constructionutil.h:887
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator, bsl::integral_constant< int, e_USES_ALLOCATOR_ARG_T_TRAITS >)
Definition bslma_constructionutil.h:1380
Definition bslma_constructionutil.h:1096
Definition bslma_constructionutil.h:731
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1244
static void destructiveMove(TARGET_TYPE *address, const ALLOCATOR &allocator, TARGET_TYPE *original)
Definition bslma_constructionutil.h:1296
Definition bslma_hasallocatortype.h:176
static BSLS_KEYWORD_CONSTEXPR void * voidify(TYPE *address) BSLS_KEYWORD_NOEXCEPT
Definition bslma_pointerutil.h:350
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisemoveable.h:718
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
Definition bslmf_usesallocatorargt.h:100