Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Struct template concept_interface



// In header: <boost/type_erasure/concept_interface.hpp>

template<typename Concept, typename Base, typename ID, typename Enable = void> 
struct concept_interface : public Base {


The concept_interface class can be specialized to add behavior to an any. An any inherits from all the relevant specializations of concept_interface.

concept_interface can be specialized for either primitive or composite concepts. If a concept C1 contains another concept C2, then the library guarantees that the specialization of concept_interface for C2 is a base class of the specialization for C1. This means that C1 can safely override members of C2.

concept_interface may only be specialized for user-defined concepts. The library owns the specializations of its own built in concepts.

The metafunctions derived, rebind_any, and as_param (which can be applied to Base) are useful for determining the argument and return types of functions defined in concept_interface.

For dispatching the function use call.

Template Parameters

  1. typename Concept

    The concept that we're specializing concept_interface for. One of its placeholders should be ID.

  2. typename Base

    The base of this class. Specializations of concept_interface must inherit publicly from this type.

  3. typename ID

    The placeholder representing this type.

  4. typename Enable = void

    A dummy parameter that can be used for SFINAE.