Quick Links:

bal | bbl | bdl | bsl

Classes | Public Types | Public Member Functions

bslstl::Function_Rep Class Reference

#include <bslstl_function_rep.h>

List of all members.

Classes

struct  Decay
union  ManagerRet

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

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 Component bslstl_function_rep


Member Typedef Documentation

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


Constructor & Destructor Documentation

bslstl::Function_Rep::Function_Rep ( const allocator_type allocator  )  [explicit]

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

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

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.

template<class FUNC >
void bslstl::Function_Rep::installFunc ( BSLS_COMPILERFEATURES_FORWARD_REF(FUNC)  func,
GenericInvoker  invoker 
)

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.

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.

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.

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

template<class TP >
TP* bslstl::Function_Rep::target (  )  const

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.

template<class TP , bool INPLACE>
TP* bslstl::Function_Rep::targetRaw (  )  const

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.

allocator_type bslstl::Function_Rep::get_allocator (  )  const

Return the allocator used to supply memory for this object.

GenericInvoker* bslstl::Function_Rep::invoker (  )  const

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

bool bslstl::Function_Rep::isEmpty (  )  const

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

bool bslstl::Function_Rep::isInplace (  )  const

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

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: