Boost C++ Libraries

...one 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 for the latest Boost documentation.
PrevUpHomeNext

Class template param

boost::type_erasure::param — A wrapper to help with overload resolution for functions operating on an any.

Synopsis

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

template<typename Concept, typename T> 
class param {
public:
  // construct/copy/destruct
  template<typename U> param(any< Concept, U > &);
  template<typename U> param(const any< Concept, U > &);
  template<typename U> param(any< Concept, U > &&);

  // public member functions
  any< Concept, T > get() const;
};

Description

The template arguments are interpreted in the same way as any.

A parameter of type param can be initialized with an any that has the same Concept and base placeholder when there exists a corresponding standard conversion for the placeholder. A conversion sequence from any<C, P> to param<C, P1> is a better conversion sequence than any<C, P> to param<C, P2> iff the corresponding placeholder standard conversion sequence from P to P1 is a better conversion sequence than P to P2.

[Note] Note

Overloading based on cv-qualifiers and rvalue-ness is only supported in C++11. In C++03, all conversion sequences from any to param have the same rank.

Example:

void f(param<C, _a&>);
void f(param<C, const _a&>);
void g(param<C, const _a&>);
void g(param<C, _a&&>);

any<C, _a> a;
f(any<C, _a>()); // calls void f(param<C, const _a&>);
f(a);            // calls void f(param<C, _a&>); (ambiguous in C++03)
g(any<C, _a>()); // calls void g(param<C, _a&&>); (ambiguous in C++03)
g(a);            // calls void g(param<C, const _a&>);

param public construct/copy/destruct

  1. template<typename U> param(any< Concept, U > & a);
  2. template<typename U> param(const any< Concept, U > & a);
  3. template<typename U> param(any< Concept, U > && a);

param public member functions

  1. any< Concept, T > get() const;

    Returns the stored any.


PrevUpHomeNext