8#ifndef INCLUDED_BSLSTL_FUNCTION_INVOKERUTIL
9#define INCLUDED_BSLSTL_FUNCTION_INVOKERUTIL
152#include <bslscm_version.h>
176#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
180# define COMPILING_BSLSTL_FUNCTION_INVOKERUTIL_H
182# undef COMPILING_BSLSTL_FUNCTION_INVOKERUTIL_H
185#ifndef BSLS_PLATFORM_CMP_SUN
186#define BSLSTL_FUNCTION_INVOKERUTIL_CAST_RESULT(RET, X) static_cast<RET>(X)
188#define BSLSTL_FUNCTION_INVOKERUTIL_CAST_RESULT(RET, X) (RET)(X)
191#if defined(BSLMF_INVOKERESULT_SUPPORT_CPP17_SEMANTICS) \
192 && defined(BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE) \
193 && defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
194 && defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY)
195#define BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
201#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
204template <
class PROTOTYPE,
class FUNC>
205struct Function_InvokerUtil_IsFuncInvocable;
234#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
258 template <
class PROTOTYPE,
class FUNC>
259 struct IsFuncInvocable
260 : Function_InvokerUtil_IsFuncInvocable<PROTOTYPE, FUNC> {
269 template <
class PROTOTYPE>
277 template <
class PROTOTYPE,
class FUNC>
299 static bool isNull(
const FUNC&);
310 static bool isNull(FUNC *f);
314template <
class CLASS,
class MEMTYPE>
325#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
331#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
334template <
class VOID_TYPE,
class RET,
class FUNC,
class... ARGS>
335struct Function_InvokerUtil_IsFuncInvocableImp;
345template <
class RET,
class FUNC,
class... ARGS>
346struct Function_InvokerUtil_IsFuncInvocable<RET(ARGS...), FUNC>
347: Function_InvokerUtil_IsFuncInvocableImp<void, RET, FUNC, ARGS...> {
356struct Function_InvokerUtil_ForwardType;
359template <
class FROM,
class TO>
360struct Function_InvokerUtil_IsExplicitlyConvertible;
363template <
class FUNC,
class... ARGS>
364struct Function_InvokerUtil_ResultType;
376template <
class VOID_TYPE,
class RET,
class FUNC,
class... ARGS>
397template <
class RET,
class FUNC,
class... ARGS>
398struct Function_InvokerUtil_IsFuncInvocableImp<
399 typename
bslmf::VoidType<
400 typename Function_InvokerUtil_ResultType<FUNC, ARGS...>::type>::type,
405 bsl::is_void<RET>::value,
407 Function_InvokerUtil_IsExplicitlyConvertible<
408 typename Function_InvokerUtil_ResultType<FUNC, ARGS...>::type,
417template <
class VOID_TYPE,
class FUNC,
class... ARGS>
418struct Function_InvokerUtil_ResultTypeImp;
430template <
class FUNC,
class... ARGS>
431struct Function_InvokerUtil_ResultType
432: Function_InvokerUtil_ResultTypeImp<void, FUNC, ARGS...> {
450template <
class VOID_TYPE,
class FUNC,
class... ARGS>
451struct Function_InvokerUtil_ResultTypeImp {
454template <
class FUNC,
class... ARGS>
455struct Function_InvokerUtil_ResultTypeImp<
456 typename
bslmf::VoidType<
457 typename Function_InvokerUtil_ForwardType<ARGS>::Type...>::type,
461 typename bsl::add_lvalue_reference<typename bslalg::NothrowMovableUtil::
462 UnwrappedType<FUNC>::type>::type,
463 typename Function_InvokerUtil_ForwardType<ARGS>::Type...> {
482template <
class VOID_TYPE,
class ARG>
483struct Function_InvokerUtil_ForwardTypeImp;
497struct Function_InvokerUtil_ForwardType
498: Function_InvokerUtil_ForwardTypeImp<void, ARG> {
513template <
class VOID_TYPE,
class ARG>
514struct Function_InvokerUtil_ForwardTypeImp {
527struct Function_InvokerUtil_ForwardTypeImp<
528 typename
bslmf::VoidType<decltype(
529 bslmf::ForwardingTypeUtil<ARG>::forwardToTarget(
530 std::declval<typename bsl::add_lvalue_reference<
531 typename bslmf::ForwardingType<ARG>::Type>::type>()))>::type,
551template <
class VOID_TYPE,
class FROM,
class TO>
552struct Function_InvokerUtil_IsExplicitlyConvertibleImp;
560template <
class FROM,
class TO>
561struct Function_InvokerUtil_IsExplicitlyConvertible
562: Function_InvokerUtil_IsExplicitlyConvertibleImp<void, FROM, TO> {
569template <
class FROM_TO>
570struct Function_InvokerUtil_IsExplicitlyConvertible<FROM_TO, FROM_TO>
584template <
class VOID_TYPE,
class FROM,
class TO>
585struct Function_InvokerUtil_IsExplicitlyConvertibleImp :
bsl::false_type {
593template <
class FROM,
class TO>
594struct Function_InvokerUtil_IsExplicitlyConvertibleImp<
595 typename
bslmf::VoidType<decltype(
596 static_cast<TO>(std::declval<FROM>()))>::type,
617template <
int INVOCATION_TYPE,
class PROTOTYPE,
class FUNC>
620#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
625template <
class FUNC,
class RET,
class... ARGS>
627 RET(ARGS...), FUNC> {
638template <
class FUNC,
class RET,
class ARG0,
class... ARGS>
640 RET(ARG0, ARGS...), FUNC> {
675template <
class MEMBER_TYPE,
class CLASS_TYPE,
class RET,
class ARG0>
677 RET(ARG0), MEMBER_TYPE CLASS_TYPE::*> {
680 typedef MEMBER_TYPE CLASS_TYPE::* Func;
707template <
class FUNC,
class RET,
class... ARGS>
709 RET(ARGS...), FUNC> {
721template <
class FUNC,
class RET,
class... ARGS>
723 RET(ARGS...), FUNC> {
743template <
class PROTOTYPE>
751template <
class PROTOTYPE,
class FUNC>
765 static const int k_INVOCATION_TYPE =
769 Soo::IsInplaceFunc<FUNC>::value ? e_InplaceFunctor :
778 UwFuncType> DispatcherClass;
792 &DispatcherClass::invoke);
815template <
class CLASS,
class MEMTYPE>
828#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
830template <
class FUNC,
class RET,
class... ARGS>
833 RET(ARGS...), FUNC>::
850template <
class FUNC,
class RET,
class ARG0,
class... ARGS>
854 RET(ARG0, ARGS...), FUNC>::
867 RET, (
const_cast<Arg0Ref
>(obj).*f)(
871template <
class FUNC,
class RET,
class ARG0,
class... ARGS>
875 RET(ARG0, ARGS...), FUNC>::
888 RET, ((*
const_cast<Arg0Ref
>(obj)).*f)(
892template <
class FUNC,
class RET,
class ARG0,
class... ARGS>
895 RET(ARG0, ARGS...), FUNC>::
913 invokeImp(IsDirect(), f, obj,
917template <
class MEMBER_TYPE,
class CLASS_TYPE,
class RET,
class ARG0>
921 RET(ARG0), MEMBER_TYPE CLASS_TYPE::*>::
933 RET, (
const_cast<Arg0Ref
>(obj).*f));
936template <
class MEMBER_TYPE,
class CLASS_TYPE,
class RET,
class ARG0>
940 RET(ARG0), MEMBER_TYPE CLASS_TYPE::*>::
952 RET, ((*
const_cast<Arg0Ref
>(obj)).*f));
955template <
class MEMBER_TYPE,
class CLASS_TYPE,
class RET,
class ARG0>
958 RET(ARG0), MEMBER_TYPE CLASS_TYPE::*>::
959invoke(
const Function_Rep *rep,
969 const volatile CLASS_TYPE *
972 Func f = *rep->targetRaw<Func,
true>();
975 RET, invokeImp(IsDirect(), f, obj));
978template <
class FUNC,
class RET,
class... ARGS>
981 RET(ARGS...), FUNC>::
994template <
class FUNC,
class RET,
class... ARGS>
997 RET(ARGS...), FUNC>::
1001 FUNC& f = *rep->
targetRaw<FUNC,
false>();
Definition bslmf_invokeresult.h:358
Provide a namespace for the forwardToTarget function.
Definition bslmf_forwardingtype.h:454
Imp::Type Type
Definition bslmf_forwardingtype.h:439
Definition bslstl_function_rep.h:132
void GenericInvoker()
Definition bslstl_function_rep.h:369
Definition bslstl_function_smallobjectoptimization.h:78
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLSTL_FUNCTION_INVOKERUTIL_CAST_RESULT(RET, X)
Definition bslstl_function_invokerutil.h:186
TP * targetRaw() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function_rep.h:725
BloombergLP::bsls::Nullptr_Impl::Type nullptr_t
Definition bsls_nullptr.h:281
Definition bdlbb_blob.h:576
Definition bslstl_algorithm.h:82
Definition bslmf_addlvaluereference.h:126
Definition bslmf_conditional.h:120
Definition bslmf_integralconstant.h:244
Definition bslmf_isconvertible.h:867
Definition bslmf_ismemberpointer.h:143
NothrowMovableUtil_Traits< TYPE >::UnwrappedType type
Definition bslalg_nothrowmovableutil.h:370
static UnwrappedType< TYPE >::type & unwrap(TYPE &f)
Definition bslmf_functionpointertraits.h:153
Definition bslmf_memberfunctionpointertraits.h:164
Definition bslmf_memberfunctionpointertraits.h:150
t_TYPE type
Definition bslmf_movableref.h:1177
static bool isNull(MEMTYPE CLASS::*f)
Definition bslstl_function_invokerutil.h:294
static bool isNull(const FUNC &)
Return false.
Definition bslstl_function_invokerutil.h:803
static RET invoke(const Function_Rep *rep, typename bslmf::ForwardingType< ARG0 >::Type obj)
Definition bslstl_function_invokerutil.h:618
Definition bslstl_function_invokerutil.h:216
@ e_Null
Definition bslstl_function_invokerutil.h:222
@ e_MemDataPtr
Definition bslstl_function_invokerutil.h:225
@ e_FunctionPtr
Definition bslstl_function_invokerutil.h:223
@ e_InplaceFunctor
Definition bslstl_function_invokerutil.h:226
@ e_OutofplaceFunctor
Definition bslstl_function_invokerutil.h:227
@ e_MemFunctionPtr
Definition bslstl_function_invokerutil.h:224
static GenericInvoker * invokerForFunc(const bsl::nullptr_t &)
Function_Rep::GenericInvoker GenericInvoker
Definition bslstl_function_invokerutil.h:232
static GenericInvoker * invokerForFunc(const FUNC &f)