BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl::Function_Rep Class Reference

#include <bslstl_function_rep.h>

Public Types

typedef bsl::allocator< char > allocator_type
 
typedef void GenericInvoker()
 

Public Member Functions

 Function_Rep (const allocator_type &allocator) BSLS_KEYWORD_NOEXCEPT
 
 ~Function_Rep ()
 
void copyInit (const Function_Rep &original)
 
template<class FUNC >
void installFunc (BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func, GenericInvoker invoker)
 
void makeEmpty ()
 
void moveInit (Function_Rep *from)
 
void swap (Function_Rep &other) BSLS_KEYWORD_NOEXCEPT
 
template<class TP >
TP * target () const BSLS_KEYWORD_NOEXCEPT
 
template<class TP , bool INPLACE>
TP * targetRaw () const BSLS_KEYWORD_NOEXCEPT
 
allocator_type get_allocator () const BSLS_KEYWORD_NOEXCEPT
 Return the allocator used to supply memory for this object.
 
GenericInvokerinvoker () const BSLS_KEYWORD_NOEXCEPT
 
bool isEmpty () const BSLS_KEYWORD_NOEXCEPT
 
bool isInplace () const BSLS_KEYWORD_NOEXCEPT
 
const std::type_info & target_type () const BSLS_KEYWORD_NOEXCEPT
 
template<class FUNC , bool INPLACE>
bslstl::Function_Rep::ManagerRet functionManager (ManagerOpCode opCode, Function_Rep *rep, void *srcVoidPtr)
 

Detailed Description

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

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).

See bslstl_function_rep

Member Typedef Documentation

◆ 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.

◆ GenericInvoker

typedef void bslstl::Function_Rep::GenericInvoker()

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

Constructor & Destructor Documentation

◆ ~Function_Rep()

bslstl::Function_Rep::~Function_Rep ( )

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).

Member Function Documentation

◆ copyInit()

void bslstl::Function_Rep::copyInit ( const Function_Rep original)

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.

◆ isInplace()

bool bslstl::Function_Rep::isInplace ( ) const

The isInplace function is public in BDE legacy mode and private otherwise. Return true if the target is allocated in place within the small-object buffer of this object; otherwise return false.

◆ makeEmpty()

void bslstl::Function_Rep::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()

void bslstl::Function_Rep::moveInit ( Function_Rep from)

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()

void bslstl::Function_Rep::swap ( Function_Rep other)

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_type()

const std::type_info & bslstl::Function_Rep::target_type ( ) const

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.


The documentation for this class was generated from the following file: