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);
181 operator std::size_t()
const;
187 operator TP *()
const;
193 template <
class TYPE>
195 :
bsl::decay<typename bslmf::MovableRefUtil::RemoveReference<TYPE>::type> {
219 ManagerRet (*d_funcManager_p)(ManagerOpCode opCode,
227 void (*d_invoker_p)();
316 template <
class FUNC,
bool INPLACE>
317 static ManagerRet functionManager(ManagerOpCode opCode,
331 void allocateBuf(std::size_t sooFuncSize);
339 template <
class FUNC>
340 void constructTarget(FUNC& func);
341 template <
class FUNC>
350 template <
class FUNC>
412 template <
class FUNC>
456 template<class TP,
bool INPLACE> TP*
targetRaw() const
474#ifdef BDE_OMIT_INTERNAL_DEPRECATED
514bslstl::Function_Rep::ManagerRet::operator std::size_t()
const
521bslstl::Function_Rep::ManagerRet::operator TP *()
const
523 return static_cast<TP*
>(d_asPtr_p);
531template <
class FUNC,
bool INPLACE>
532bslstl::Function_Rep::ManagerRet
533bslstl::Function_Rep::functionManager(ManagerOpCode opCode,
547 static const std::size_t k_SOO_FUNC_SIZE =
548 (INPLACE && ! Soo::IsInplaceFunc<FUNC>::value) ?
558 case e_MOVE_CONSTRUCT: {
563 FUNC& original = *
static_cast<FUNC *
>(srcVoidPtr);
564 ConstructionUtil::construct(
target,
569 case e_COPY_CONSTRUCT: {
573 const FUNC& original = *
static_cast<FUNC *
>(srcVoidPtr);
574 ConstructionUtil::construct(
target, rep->d_allocator, original);
581 case e_DESTRUCTIVE_MOVE: {
582 FUNC *fromPtr =
static_cast<FUNC*
>(srcVoidPtr);
583 ConstructionUtil::destructiveMove(
target, rep->d_allocator, fromPtr);
587 return k_SOO_FUNC_SIZE;
591 std::type_info *expType =
static_cast<std::type_info *
>(srcVoidPtr);
592 if (*expType !=
typeid(FUNC)) {
594 return static_cast<FUNC*
>(0);
599 case e_GET_TYPE_ID: {
601 return const_cast<std::type_info*
>(&
typeid(FUNC));
607 return k_SOO_FUNC_SIZE;
612void bslstl::Function_Rep::constructTarget(FUNC& func)
618 const DecayedFunc& decayedFunc = func;
621 typedef typename NMUtil::UnwrappedType<DecayedFunc>::type UnwrappedFunc;
622 const UnwrappedFunc& unwrappedFunc = NMUtil::unwrap(decayedFunc);
625 e_COPY_CONSTRUCT,
this, &
const_cast<UnwrappedFunc&
>(unwrappedFunc));
645 DecayedFunc& decayedFunc = func;
648 typedef typename NMUtil::UnwrappedType<DecayedFunc>::type UnwrappedFunc;
649 UnwrappedFunc& unwrappedFunc = NMUtil::unwrap(decayedFunc);
651 d_funcManager_p(e_MOVE_CONSTRUCT,
this, &unwrappedFunc);
660 if (d_funcManager_p) {
661 ret = d_funcManager_p(e_GET_SIZE,
662 const_cast<Function_Rep*
>(
this), 0);
672 : d_allocator(allocator)
693 static const std::size_t k_SOO_FUNC_SIZE =
695 static const bool k_INPLACE = Soo::IsInplaceFunc<DecayedFunc>::value;
697 allocateBuf(k_SOO_FUNC_SIZE);
707 d_funcManager_p = &functionManager<UnwrappedFunc, k_INPLACE>;
722 if (! d_funcManager_p) {
726 const std::type_info& tpTypeInfo =
typeid(TP);
728 void *ret = d_funcManager_p(e_GET_TARGET,
730 const_cast<std::type_info*
>(&tpTypeInfo));
738template <
class TP,
bool INPLACE>
746 return static_cast<TP*
>(INPLACE ? &d_objbuf : d_objbuf.
d_object_p);
767 return 0 == d_invoker_p;
Definition bslma_bslallocator.h:588
Definition bslmf_decay.h:158
decay_imp< U, k_ISARRAY, k_ISFUNC >::type type
Definition bslmf_decay.h:167
Definition bslma_allocator.h:545
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:375
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:371
Definition bslstl_function_smallobjectoptimization.h:170
Definition bslstl_function_smallobjectoptimization.h:78
static const std::size_t k_NON_SOO_SMALL_SIZE
Definition bslstl_function_smallobjectoptimization.h:142
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLMF_MOVABLEREF_DEDUCE(...)
Definition bslmf_movableref.h:691
#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
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return the allocator used to supply memory for this object.
Definition bslstl_function_rep.h:752
void installFunc(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func, GenericInvoker invoker)
Definition bslstl_function_rep.h:680
bool isEmpty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:765
TP * targetRaw() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:740
ManagerRet(std::size_t s)
Create a union holding the specified s size_t.
Definition bslstl_function_rep.h:501
GenericInvoker * invoker() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:759
TP * target() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:720
Definition bslstl_algorithm.h:84
Definition bdldfp_decimal.h:5549
Definition bslalg_nothrowmovableutil.h:353
NothrowMovableUtil_Traits< TYPE >::UnwrappedType type
Definition bslalg_nothrowmovableutil.h:376
Definition bslalg_nothrowmovableutil.h:346
Definition bslma_constructionutil.h:731
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1039
Definition bslstl_function_smallobjectoptimization.h:113
void * d_object_p
Definition bslstl_function_smallobjectoptimization.h:116