8#ifndef INCLUDED_BSLSTL_FUNCTION_REP
9#define INCLUDED_BSLSTL_FUNCTION_REP
91#include <bslscm_version.h>
135#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
139 static const std::size_t k_NON_SOO_SMALL_SIZE =
164 std::size_t d_asSize_t;
171 ManagerRet(std::size_t s);
180 operator std::size_t()
const;
185 operator TP *()
const;
191 template <
class TYPE>
193 :
bsl::decay<typename bslmf::MovableRefUtil::RemoveReference<TYPE>::type> {
217 ManagerRet (*d_funcManager_p)(ManagerOpCode opCode,
224 void (*d_invoker_p)();
313 template <
class FUNC,
bool INPLACE>
314 static ManagerRet functionManager(ManagerOpCode opCode,
328 void allocateBuf(std::size_t sooFuncSize);
335 template <
class FUNC>
336 void constructTarget(FUNC& func);
337 template <
class FUNC>
345 template <
class FUNC>
403 template <
class FUNC>
441 template<class TP,
bool INPLACE> TP*
targetRaw() const
459#ifdef BDE_OMIT_INTERNAL_DEPRECATED
499bslstl::Function_Rep::ManagerRet::operator std::size_t()
const
506bslstl::Function_Rep::ManagerRet::operator TP *()
const
508 return static_cast<TP*
>(d_asPtr_p);
516template <
class FUNC,
bool INPLACE>
517bslstl::Function_Rep::ManagerRet
518bslstl::Function_Rep::functionManager(ManagerOpCode opCode,
532 static const std::size_t k_SOO_FUNC_SIZE =
533 (INPLACE && ! Soo::IsInplaceFunc<FUNC>::value) ?
543 case e_MOVE_CONSTRUCT: {
548 FUNC& original = *
static_cast<FUNC *
>(srcVoidPtr);
549 ConstructionUtil::construct(
target,
554 case e_COPY_CONSTRUCT: {
558 const FUNC& original = *
static_cast<FUNC *
>(srcVoidPtr);
559 ConstructionUtil::construct(
target, rep->d_allocator, original);
566 case e_DESTRUCTIVE_MOVE: {
567 FUNC *fromPtr =
static_cast<FUNC*
>(srcVoidPtr);
568 ConstructionUtil::destructiveMove(
target, rep->d_allocator, fromPtr);
572 return k_SOO_FUNC_SIZE;
576 std::type_info *expType =
static_cast<std::type_info *
>(srcVoidPtr);
577 if (*expType !=
typeid(FUNC)) {
579 return static_cast<FUNC*
>(0);
584 case e_GET_TYPE_ID: {
586 return const_cast<std::type_info*
>(&
typeid(FUNC));
592 return k_SOO_FUNC_SIZE;
597void bslstl::Function_Rep::constructTarget(FUNC& func)
603 const DecayedFunc& decayedFunc = func;
606 typedef typename NMUtil::UnwrappedType<DecayedFunc>::type UnwrappedFunc;
607 const UnwrappedFunc& unwrappedFunc = NMUtil::unwrap(decayedFunc);
610 e_COPY_CONSTRUCT,
this, &
const_cast<UnwrappedFunc&
>(unwrappedFunc));
630 DecayedFunc& decayedFunc = func;
633 typedef typename NMUtil::UnwrappedType<DecayedFunc>::type UnwrappedFunc;
634 UnwrappedFunc& unwrappedFunc = NMUtil::unwrap(decayedFunc);
636 d_funcManager_p(e_MOVE_CONSTRUCT,
this, &unwrappedFunc);
645 if (d_funcManager_p) {
646 ret = d_funcManager_p(e_GET_SIZE,
647 const_cast<Function_Rep*
>(
this), 0);
657 : d_allocator(allocator)
678 static const std::size_t k_SOO_FUNC_SIZE =
680 static const bool k_INPLACE = Soo::IsInplaceFunc<DecayedFunc>::value;
682 allocateBuf(k_SOO_FUNC_SIZE);
692 d_funcManager_p = &functionManager<UnwrappedFunc, k_INPLACE>;
707 if (! d_funcManager_p) {
711 const std::type_info& tpTypeInfo =
typeid(TP);
713 void *ret = d_funcManager_p(e_GET_TARGET,
715 const_cast<std::type_info*
>(&tpTypeInfo));
723template <
class TP,
bool INPLACE>
731 return static_cast<TP*
>(INPLACE ? &d_objbuf : d_objbuf.
d_object_p);
752 return 0 == d_invoker_p;
Definition bslma_bslallocator.h:580
Definition bslmf_decay.h:157
decay_imp< U, k_ISARRAY, k_ISFUNC >::type type
Definition bslmf_decay.h:166
Definition bslma_allocator.h:457
Definition bslstl_function_rep.h:132
void swap(Function_Rep &other) BSLS_KEYWORD_NOEXCEPT
const std::type_info & target_type() const BSLS_KEYWORD_NOEXCEPT
void GenericInvoker()
Definition bslstl_function_rep.h:369
bool isInplace() const BSLS_KEYWORD_NOEXCEPT
void copyInit(const Function_Rep &original)
void moveInit(Function_Rep *from)
bsl::allocator< char > allocator_type
Definition bslstl_function_rep.h:365
Definition bslstl_function_smallobjectoptimization.h:167
Definition bslstl_function_smallobjectoptimization.h:78
static const std::size_t k_NON_SOO_SMALL_SIZE
Definition bslstl_function_smallobjectoptimization.h:140
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLMF_MOVABLEREF_DEDUCE(...)
Definition bslmf_movableref.h:690
#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
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return the allocator used to supply memory for this object.
Definition bslstl_function_rep.h:737
void installFunc(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func, GenericInvoker invoker)
Definition bslstl_function_rep.h:665
bool isEmpty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:750
TP * targetRaw() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:725
ManagerRet(std::size_t s)
Create a union holding the specified s size_t.
Definition bslstl_function_rep.h:486
GenericInvoker * invoker() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:744
TP * target() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:705
Definition bslstl_algorithm.h:82
Definition bdldfp_decimal.h:5188
Definition bslalg_nothrowmovableutil.h:351
NothrowMovableUtil_Traits< TYPE >::UnwrappedType type
Definition bslalg_nothrowmovableutil.h:370
Namesapace for NothrowMovableWrapper traits and utilities.
Definition bslalg_nothrowmovableutil.h:344
Definition bslma_constructionutil.h:740
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1032
Definition bslstl_function_smallobjectoptimization.h:112
void * d_object_p
Definition bslstl_function_smallobjectoptimization.h:115