This is a component‐private class. Do not use.

Synopsis

Declared in <bslstl_function_rep.h>

class Function_Rep;

Description

This class provides a non‐template representation for a bsl::function instance. It handles all of the object‐management parts of bsl::function that are not specific to the prototype (argument list and return type), e.g., storing, copying, and moving the function object, but not invoking the function (which requires knowledge of the prototype). These management methods are run‐time polymorphic, and therefore do not require that this class be a template (although several of the member functions are templates).

Type Aliases

Name

Description

GenericInvoker

A "generic" function type analogous to the data type void (though without the language support provided by void).

allocator_type

This class does not conform to any specific interface so is not allocator‐aware in the strict sense. However, this type does hold an allocator for its AA client and therefore uses the type name for the allocator preferred by AA types.

Member Functions

Name

Description

Function_Rep [constructor]

Create an empty object using the specified allocator to supply memory.

~Function_Rep [destructor]

Destroy this object and its target object (if any) and deallocate memory for the target object (if not in‐place). This destructor is implemented to correctly deallocate a target object that has been allocated but not constructed (e.g., if an exception is thrown while constructing the target).

copyInit

Copy‐initialize this rep from the specified original rep. If an exception is thrown by the copy, the only valid subsequent operation on this object is destruction. The behavior is undefined unless this object is empty before the call.

get_allocator

Return the allocator used to supply memory for this object.

installFunc

Do nothing if the specified func is a null pointer, otherwise allocate storage (either in‐place within this object's small‐object buffer or out‐of‐place from the allocator) to hold a target of (template parameter) type FUNC, forward the func to the constructor of the new target, set d_funcManager_p to manage the new target, and set d_invoker_p to the specified invoker address. The behavior is undefined unless this object is empty on entry. Note that FUNC will not qualify for the small‐object optimization unless bsl::is_nothrow_move_constructible<FUNC>::value is true.

invoker

Return a pointer the invoker function set using installFunc or a null pointer if this object is empty.

isEmpty

Return true if invoker() is a null pointer, indicating that this object has no target object.

isInplace

Return true if the target is allocated in place within the small‐object buffer of this object; otherwise return false.

makeEmpty

Change this object to be an empty object without changing its allocator. Any previous target is destroyed and deallocated. Note that value returned by get_allocator().mechanism() might change, but will point to an allocator with the same type managing the same memory resource.

moveInit

Move‐initialize this rep from the rep at the specified from address, leaving the latter empty. If 'this‐>get_allocator() != from‐>get_allocator()', this function degenerates to a call to copyInit(*from). The behavior is undefined unless this rep is empty before the call.

swap

Exchange this object's target object, manager function, and invoker with those of the specified other object. The behavior is undefined unless this‐>get_allocator() == other‐>get_allocator().

target

If typeid(TP) == this‐>target_type(), return a pointer offering modifiable access to this object's target; otherwise return a null pointer. Note that this function is const but returns a non‐`const` pointer because, according to the C++ Standard, function (and therefore this representation) does not adhere to logical constness conventions.

targetRaw

Return a pointer offering modifiable access to this object's target. If INPLACE is true, then the object is assumed to be allocated inplace in the small object buffer. Note that this function is const but returns a non‐`const` pointer because this type does not adhere to logical constness conventions. The behavior is undefined unless typeid(TP) == this‐>target_type() and INPLACE correctly identifies whether the target is inplace.

target_type

Return a reference to the type_info for the type of the current target object or typeid(void) if this object is empty. If the target type is a specialization of bslalg::NothrowMovableWrapper, then the returned type_info is for the unwrapped type.

Created with MrDocs