BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP > Class Template Reference

#include <bsltf_degeneratefunctor.h>

Inheritance diagram for bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >:

Public Member Functions

 DegenerateFunctor (const DegenerateFunctor &original)
 
 DegenerateFunctor (bslmf::MovableRef< DegenerateFunctor > original)
 
void exchangeValues (DegenerateFunctor *other)
 

Static Public Member Functions

static DegenerateFunctor cloneBaseObject (const FUNCTOR &base)
 

Detailed Description

template<class FUNCTOR, bool ENABLE_SWAP = true>
class bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >

This test class template adapts a CopyConstructible class to offer a minimal or outright obstructive interface for testing generic code. To support the testing of standard containers, this adapter will be MoveConstructible, CopyConstructible, and nothrow Destructible as long as the adapted FUNCTOR satisfies the same requirements. This class will further be Swappable if (the template parameter) ENABLE_SWAP is true and the adapted FUNCTOR is MoveConstructible. The (inherited) function call operator should be the only other available method, no other operation (e.g., the unary address-of operator) should be usable. We take advantage of the fact that defining a copy constructor inhibits the generation of a default constructor, and that constructors are not inherited by a derived class. DegenerateFunctor objects must be created through either the copy constructor, or by wrapping a FUNCTOR object through the static factory method of this class, cloneBaseObject.

Constructor & Destructor Documentation

◆ DegenerateFunctor() [1/2]

template<class FUNCTOR , bool ENABLE_SWAP>
bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >::DegenerateFunctor ( const DegenerateFunctor< FUNCTOR, ENABLE_SWAP > &  original)
inline

Create a DegenerateFunctor having the same value the specified original.

◆ DegenerateFunctor() [2/2]

template<class FUNCTOR , bool ENABLE_SWAP>
bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >::DegenerateFunctor ( bslmf::MovableRef< DegenerateFunctor< FUNCTOR, ENABLE_SWAP > >  original)
inline

Create a DegenerateFunctor having the same value the specified original, and leaveoriginal' in an unspecified (but valid) state.

Member Function Documentation

◆ cloneBaseObject()

template<class FUNCTOR , bool ENABLE_SWAP>
DegenerateFunctor< FUNCTOR, ENABLE_SWAP > bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >::cloneBaseObject ( const FUNCTOR &  base)
inlinestatic

Create a DegenerateFunctor object wrapping a copy of the specified base. Note that this method is supplied so that the only publicly accessible constructor is the copy constructor.

◆ exchangeValues()

template<class FUNCTOR , bool ENABLE_SWAP>
void bsltf::DegenerateFunctor< FUNCTOR, ENABLE_SWAP >::exchangeValues ( DegenerateFunctor< FUNCTOR, ENABLE_SWAP > *  other)
inline

Swap the wrapped FUNCTOR object, by move-constructing a temporary object from the specified *other, then alternately destroying and in-place move-constructing new values for each of *other and *this. Note that this function is deliberately not named swap as some "clever" template libraries may try to call a member-swap function when they can find it, and ADL-swap is not available. Also note that this overload is needed only so that the ADL-enabling free-function swap can be defined, as the native std library std::swap function will not accept this class (with its deliberate degenerate nature) on AIX, or on Windows with Visual C++ prior to VC2010.


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