BloombergLP::bsltf::DegenerateFunctor

Awkward CopyConstructible functor adapter for testing generic code.

Synopsis

Declared in <bsltf_degeneratefunctor.h>

template<
    class FUNCTOR,
    bool ENABLE_SWAP = true>
class DegenerateFunctor;

Description

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.

Member Functions

NameDescription
DegenerateFunctor [constructor]Constructors
exchangeValues Swap the wrapped FUNCTOR values with those of the specified other.

Static Member Functions

NameDescription
cloneBaseObject Create a DegenerateFunctor wrapping a copy of the specified base.

Using Declarations

NameDescription
operator() Expose the overloaded function call operator from the parameterizing class FUNCTOR.

Non-Member Functions

NameDescription
swapExchange the values of the specified lhs and rhs objects.