8#ifndef INCLUDED_BSLSTL_FUNCTION
9#define INCLUDED_BSLSTL_FUNCTION
642#include <bslscm_version.h>
668#ifdef BDE_BUILD_TARGET_EXC
671#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
677#ifdef BSLSTL_FUNCTION_VARIADIC_LIMIT
678#define BSLSTL_FUNCTION_INVOKERUTIL_VARIADIC_LIMIT \
679 BSLSTL_FUNCTION_VARIADIC_LIMIT
691#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
695#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
701# define COMPILING_BSLSTL_FUNCTION_H
703# undef COMPILING_BSLSTL_FUNCTION_H
709#ifdef BSLS_ASSERTIMPUTIL_AVOID_STRING_CONSTANTS
711extern const char s_bslstl_function_h[];
712#undef BSLS_ASSERTIMPUTIL_FILE
713#define BSLS_ASSERTIMPUTIL_FILE BloombergLP::s_bslstl_function_h
721template <
class PROTOTYPE>
728#ifndef BDE_OMIT_INTERNAL_DEPRECATED
736template <
class PROTOTYPE>
762template <
class PROTOTYPE>
769template <
class RET,
class ARG>
777 "deprecated_cpp17_standard_library_features",
779 typedef ARG argument_type;
785template <class RET, class ARG1, class ARG2>
793 "deprecated_cpp17_standard_library_features",
795 typedef ARG1 first_argument_type;
798 "deprecated_cpp17_standard_library_features",
802 typedef ARG2 second_argument_type;
809#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
811template <
class PROTOTYPE>
827template <
class RET,
class... ARGS>
880 RET operator()(ARGS... args)
const;
904template <
class PROTOTYPE,
class FUNC>
945template <
class PROTOTYPE>
946class function :
public BloombergLP::bslstl::Function_Variadic<PROTOTYPE> {
950 typedef BloombergLP::bslstl::Function_Variadic<PROTOTYPE> Base;
951 typedef BloombergLP::bslstl::Function_Rep Function_Rep;
952 typedef BloombergLP::bslmf::MovableRefUtil MovableRefUtil;
957 template <
class FROM,
class TO>
958 struct IsReferenceCompatible
959 : BloombergLP::bslstl::Function_IsReferenceCompatible<FROM, TO>::type {
965 template <
class TYPE>
966 struct Decay : MovableRefUtil::Decay<TYPE> {
973 template <
class FUNC>
974 struct IsInvocableWithPrototype
975 : BloombergLP::bslstl::Function_IsInvocableWithPrototype<PROTOTYPE, FUNC> {
978#ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
984 typedef BloombergLP::bsls::UnspecifiedBool<function> UnspecifiedBoolUtil;
985 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
994 bool operator==(
const function&)
const;
995 bool operator!=(
const function&)
const;
1007 template <
class FUNC>
1013 BloombergLP::bslma::UsesBslmaAllocator);
1015 BloombergLP::bslmf::UsesAllocatorArgT);
1051 template <class FUNC>
1054 ! IsReferenceCompatible<typename Decay<FUNC>::type,
1056 && IsInvocableWithPrototype<
1057 typename Decay<FUNC>::type>::value
1058#ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1059 && ! MovableRefUtil::IsMovableReference<FUNC>::value
1061#ifdef BSLS_PLATFORM_CMP_IBM
1089#ifdef BSLS_PLATFORM_CMP_IBM
1090 template <
class FUNC>
1094 : Base(allocator_type())
1115#ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1147 template <
class FUNC>
1148 explicit function(
const BloombergLP::bslmf::MovableRef<FUNC>& func,
1150 ! IsReferenceCompatible<
typename Decay<FUNC>::type,
1152 && IsInvocableWithPrototype<
1153 typename Decay<FUNC>::type>::value
1162 installFunc(BloombergLP::bslmf::MovableRefUtil::move(func));
1183 template <
class FUNC>
1188 ! IsReferenceCompatible<
typename Decay<FUNC>::type,
1190 && IsInvocableWithPrototype<
1191 typename Decay<FUNC>::type>::value
1192#ifdef BSLS_PLATFORM_CMP_IBM
1220#ifdef BSLS_PLATFORM_CMP_IBM
1221 template <
class FUNC>
1263 function(BloombergLP::bslmf::MovableRef<function> original)
1274 BloombergLP::bslmf::MovableRef<function> original);
1311 template <
class FUNC>
1313 ! IsReferenceCompatible<typename Decay<FUNC>::type,
function>::value
1314 && IsInvocableWithPrototype<typename Decay<FUNC>::type>::value
1323 function(allocator_arg, this->get_allocator(),
1328#ifdef BSLS_PLATFORM_CMP_IBM
1333 template <
class FUNC>
1335 operator=(FUNC *rhs)
1346 function(allocator_arg, this->get_allocator(), rhs).
swap(*
this);
1358 template <
class FUNC>
1360 IsInvocableWithPrototype<typename Decay<FUNC>::type>::value
1384 using Base::operator();
1398#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1417 return UnspecifiedBoolUtil::makeValue(0 != this->d_rep.invoker());
1434#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1451 operator const BloombergLP::bdef_Function<PROTOTYPE *>&()
const
1472#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1477template<
class RET,
class... ARGS>
1482template<
class ALLOC,
class RET,
class... ARGS>
1491struct FunctionDeductionHelper {
1495 template<
class FUNCTOR>
1496 struct StripSignature {};
1498 template<
class RET,
class FUNCTOR,
class ...ARGS>
1499 struct StripSignature<RET (FUNCTOR::*) (ARGS...)>
1500 {
using Sig = RET(ARGS...); };
1502 template<
class RET,
class FUNCTOR,
class ...ARGS>
1503 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const>
1504 {
using Sig = RET(ARGS...); };
1506 template<
class RET,
class FUNCTOR,
class ...ARGS>
1507 struct StripSignature<RET (FUNCTOR::*) (ARGS...) noexcept>
1508 {
using Sig = RET(ARGS...); };
1510 template<
class RET,
class FUNCTOR,
class ...ARGS>
1511 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const noexcept>
1512 {
using Sig = RET(ARGS...); };
1514 template<
class RET,
class FUNCTOR,
class ...ARGS>
1515 struct StripSignature<RET (FUNCTOR::*) (ARGS...) &>
1516 {
using Sig = RET(ARGS...); };
1518 template<
class RET,
class FUNCTOR,
class ...ARGS>
1519 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const &>
1520 {
using Sig = RET(ARGS...); };
1522 template<
class RET,
class FUNCTOR,
class ...ARGS>
1523 struct StripSignature<RET (FUNCTOR::*) (ARGS...) & noexcept>
1524 {
using Sig = RET(ARGS...); };
1526 template<
class RET,
class FUNCTOR,
class ...ARGS>
1527 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const & noexcept>
1528 {
using Sig = RET(ARGS...); };
1535 class PROTOTYPE =
typename
1536 FunctionDeductionHelper::StripSignature<
decltype(&FP::operator())>::Sig
1538function(FP) -> function<PROTOTYPE>;
1545 class PROTOTYPE =
typename
1546 FunctionDeductionHelper::StripSignature<
decltype(&FP::operator())>::Sig
1548function(allocator_arg_t, ALLOC, FP) -> function<PROTOTYPE>;
1552template <
class PROTOTYPE>
1556template <
class PROTOTYPE>
1559template <
class PROTOTYPE>
1563template <
class PROTOTYPE>
1570template <
class PROTOTYPE>
1581#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1588template <
class RET,
class... ARGS>
1597template <
class RET,
class... ARGS>
1603 Invoker *invoker_p =
reinterpret_cast<Invoker*
>(d_rep.invoker());
1614 return invoker_p(&d_rep, args...);
1621#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1627#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
1638template <
class RET,
class FUNC,
class... ARGS>
1640: Function_InvokerUtil::IsFuncInvocable<RET(ARGS...), FUNC> {
1657template <
class RET,
class FUNC,
class... ARGS>
1673template <
class PROTOTYPE>
1674template <
class FUNC>
1679 typedef BloombergLP::bslstl::Function_InvokerUtil InvokerUtil;
1680 typedef InvokerUtil::GenericInvoker GenericInvoker;
1681 typedef typename Decay<FUNC>::type DecayedFunc;
1683 const DecayedFunc& decayedFunc = func;
1684 GenericInvoker *
const invoker =
1685 InvokerUtil::invokerForFunc<PROTOTYPE>(decayedFunc);
1692template <
class PROTOTYPE>
1698template <
class PROTOTYPE>
1704template <
class PROTOTYPE>
1713template <
class PROTOTYPE>
1722template <
class PROTOTYPE>
1726 this->d_rep.copyInit(original.d_rep);
1729template <
class PROTOTYPE>
1735 this->d_rep.copyInit(original.d_rep);
1738template <
class PROTOTYPE>
1742 : Base(MovableRefUtil::access(original).get_allocator())
1744 this->d_rep.moveInit(&MovableRefUtil::access(original).d_rep);
1747template <
class PROTOTYPE>
1751 BloombergLP::bslmf::MovableRef<function> original)
1754 this->d_rep.moveInit(&MovableRefUtil::access(original).d_rep);
1758template <
class PROTOTYPE>
1762 function temp(allocator_arg, this->get_allocator(),
rhs);
1763 this->d_rep.makeEmpty();
1764 this->d_rep.moveInit(&temp.d_rep);
1768template <
class PROTOTYPE>
1771 BloombergLP::bslmf::MovableRef<function>
rhs)
1773 function temp(allocator_arg, this->get_allocator(),
1774 MovableRefUtil::move(
rhs));
1775 this->d_rep.makeEmpty();
1776 this->d_rep.moveInit(&temp.d_rep);
1780template <
class PROTOTYPE>
1784 this->d_rep.makeEmpty();
1788template <
class PROTOTYPE>
1792 this->d_rep.
swap(other.d_rep);
1795template <
class PROTOTYPE>
1800 return this->d_rep.template target<TP>();
1805#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1806template <
class PROTOTYPE>
1812 return 0 != this->d_rep.invoker();
1816template <
class PROTOTYPE>
1824template <
class PROTOTYPE>
1829 return this->d_rep.template target<TP>();
1832template <
class PROTOTYPE>
1833const std::type_info&
1836 return this->d_rep.target_type();
1839#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1841template <
class PROTOTYPE>
1846 typedef BloombergLP::bdef_Function<PROTOTYPE *> Ret;
1847 return *
static_cast<Ret*
>(
this);
1850template <
class PROTOTYPE>
1853operator
const BloombergLP::bdef_Function<PROTOTYPE *>&()
const
1856 typedef const BloombergLP::bdef_Function<PROTOTYPE *> Ret;
1857 return *
static_cast<Ret*
>(
this);
1860template <
class PROTOTYPE>
1862BloombergLP::bslma::Allocator *
1865 return get_allocator().mechanism();
1868template <
class PROTOTYPE>
1877template <
class PROTOTYPE>
1885template <
class PROTOTYPE>
1893template <
class PROTOTYPE>
1901template <
class PROTOTYPE>
1909template <
class PROTOTYPE>
1926template <
class PROTO>
1943#ifdef BSLS_ASSERTIMPUTIL_AVOID_STRING_CONSTANTS
1944#undef BSLS_ASSERTIMPUTIL_FILE
1945#define BSLS_ASSERTIMPUTIL_FILE BSLS_ASSERTIMPUTIL_DEFAULTFILE
Definition bslstl_function.h:737
Forward declaration.
Definition bslstl_function.h:946
function(const BloombergLP::bslmf::MovableRef< FUNC > &func, typename enable_if< ! IsReferenceCompatible< typename Decay< FUNC >::type, function >::value &&IsInvocableWithPrototype< typename Decay< FUNC >::type >::value, int >::type=0)
Definition bslstl_function.h:1148
function(allocator_arg_t, const allocator_type &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func, typename enable_if< ! IsReferenceCompatible< typename Decay< FUNC >::type, function >::value &&IsInvocableWithPrototype< typename Decay< FUNC >::type >::value, int >::type=0)
Definition bslstl_function.h:1184
BSLMF_NESTED_TRAIT_DECLARATION(function, bsl::is_nothrow_move_constructible)
BSLMF_NESTED_TRAIT_DECLARATION(function, BloombergLP::bslma::UsesBslmaAllocator)
BSLMF_NESTED_TRAIT_DECLARATION(function, BloombergLP::bslmf::UsesAllocatorArgT)
enable_if< IsInvocableWithPrototype< typenameDecay< FUNC >::type >::value, function & >::type operator=(bsl::reference_wrapper< FUNC > rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1362
Function_Rep::allocator_type allocator_type
Definition bslstl_function.h:1020
enable_if<!IsReferenceCompatible< typenameDecay< FUNC >::type, function >::value &&IsInvocableWithPrototype< typenameDecay< FUNC >::type >::value, function & >::type operator=(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) rhs)
Definition bslstl_function.h:1316
Definition bslmf_referencewrapper.h:182
Imp::Type Type
Definition bslmf_forwardingtype.h:441
Definition bslstl_function_rep.h:132
~Function_Variadic()=default
Destroy this object and its target object.
RET result_type
Definition bslstl_function.h:860
Function_Rep d_rep
Definition bslstl_function.h:845
Function_Rep::allocator_type allocator_type
Definition bslstl_function.h:861
Definition bslstl_function.h:812
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_DEPRECATE_FEATURE(UOR, FEATURE, MESSAGE)
Definition bsls_deprecatefeature.h:387
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:651
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
BloombergLP::bslma::Allocator * allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1863
function & operator=(const function &rhs)
Definition bslstl_function.h:1760
function & operator=(BloombergLP::bslmf::MovableRef< function > rhs)
Definition bslstl_function.h:1770
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1819
const std::type_info & target_type() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1834
bool isInplace() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1870
function(allocator_arg_t, const allocator_type &allocator, const function &original)
Definition bslstl_function.h:1730
function(allocator_arg_t, const allocator_type &allocator, BloombergLP::bslmf::MovableRef< function > original)
Definition bslstl_function.h:1748
function & operator=(nullptr_t) BSLS_KEYWORD_NOEXCEPT
Set this object to empty and return *this.
Definition bslstl_function.h:1782
void swap(function &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1790
TP * target() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1798
function() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1693
function(const function &original)
Definition bslstl_function.h:1723
function(BloombergLP::bslmf::MovableRef< function > original) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1740
Definition bdlat_valuetypefunctions.h:939
BloombergLP::bsls::Nullptr_Impl::Type nullptr_t
Definition bsls_nullptr.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
bool operator==(const memory_resource &a, const memory_resource &b)
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bslstl_algorithm.h:84
Definition bdldfp_decimal.h:5549
Definition bslmf_allocatorargt.h:433
Definition bslmf_enableif.h:530
Definition bslmf_integralconstant.h:261
Definition bslmf_isfunction.h:232
Definition bslmf_isnothrowmoveconstructible.h:361
BSLS_DEPRECATE_FEATURE("bsl", "deprecated_cpp17_standard_library_features", "do not use") typedef ARG1 first_argument_type
BSLS_DEPRECATE_FEATURE("bsl", "deprecated_cpp17_standard_library_features", "do not use") typedef ARG argument_type
Definition bslstl_function.h:763
static bool isNull(const bsl::function< PROTO > &f)
Definition bslstl_function.h:1933
Definition bslstl_function_invokerutil.h:318
static BSLA_NORETURN void throwBadFunctionCall()
Definition bslstl_function.h:905