The Boost Parameter Library Reference Documentation Boost

Author: David Abrahams
Author: Daniel Wallin
Contact: dave@boost-consulting.com, dalwan01@student.umu.se
Organization: Boost Consulting
Date: 2005-07-17
Copyright: Copyright David Abrahams, Daniel Wallin 2005. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Contents

  • class template keyword
  • class template parameters
  • class templates optional, required
  • class template binding
  • class template lazy_binding
  • concept KeywordExpression, KeywordDefaultExpression
  • concept ArgumentPack
  • concept ParameterSpec
  • macro BOOST_PARAMETER_KEYWORD
  • macro BOOST_PARAMETER_FUN

class template keyword

Defined in
boost/parameter/keyword.hpp
Models
KeywordExpression
template <class Tag>
struct keyword
{
    template <class T>
    ArgumentPack operator=(T& value) const;

    template <class T>
    ArgumentPack operator=(T const& value) const;

    template <class T>
    ArgumentPack operator|(T& default_) const;

    template <class T>
    KeywordDefaultExpression operator|(T const& default_) const;

    template <class F>
    KeywordDefaultExpression operator||(F const&) const;
};

operator=

template <class T> ArgumentPack operator=(T& value) const;
template <class T> ArgumentPack operator=(T const& value) const;
Requires
Nothing.
Throws
Nothing
Returns
A model of ArgumentPack, holding value (by reference), and tagged with Tag.

operator|

template <class T> KeywordDefaultExpression operator|(T& x) const;
template <class T> KeywordDefaultExpression operator|(T const& x) const;
Throws
Nothing
Returns
An object that holds x as a default for the keyword tag Tag.

operator||

template <class F> KeywordDefaultExpression operator||(F const& fn) const;
Throws
Nothing
Requires
F is a nullary function object.

In the next two tables, fn is an object of type F.

Returns
An object that holds a reference to fn as a lazy default for the keyword tag Tag.

class template parameters

Defined in
boost/parameter/parameters.hpp
template <class P0, class P1, …, class PN>
struct parameters
{
    template <class T0, class T1, …, class TN>
    struct match
    {
        typedef … type;
    };

    template <class A0>
    ArgumentPack operator()(A0 const& a0) const;

    template <class A0, class A1>
    ArgumentPack operator()(A0 const& a0, A1 const& a1) const;

    template <class A0, class A1, …, class AN>
    ArgumentPack operator()(A0 const& a0, A1 const& a1, …, AN const& aN) const;
};

Template Parameter Semantics

<P0, …, PN> are models of ParameterSpec. If Px is not an instance of either optional or required, it is treated as a keyword tag with the same meaning as optional<Px>.

match

Used to remove a function from overload resolution using SFINAE.

template <class T0, class T1, …, class TN> struct restrict { typedef … type; };
Returns
If the supplied argument types <T0, …, TN> fulfill the requirments of the specified ParameterSpec's, match<T0, …, TN>::type exists and is constructible from parameters<P0, …, PN>. Otherwise restrict<T0, …, TN>::type doesn't exist.

operator()

template <class A0> ArgumentPack operator()(A0 const& a0) const;
template <class A0, class A1> ArgumentPack operator()(A0 const& a0, A1 const& a1) const;
…
Throws
Nothing
Returns
A composite ArgumentPack containing all arguments <A0, …, AN>. If Ax is not a model of ArgumentPack, it is transformed into one by tagging the argument with the ParameterSpec Px in it's position.

class templates optional, required

Models
ParameterSpec
Defined in
boost/parameter/parameters.hpp
template <class Tag, class Predicate = unspecified>
struct optional;

template <class Tag, class Predicate = unspecified>
struct required;

class template binding

Defined in
boost/parameter/binding.hpp

A metafunction that, given an ArgumentPack, returns the reference type of the parameter identified by Keyword. If no such parameter has been specified, returns Default.

template <class Parameters, class Keyword, class Default = unspecified>
struct binding
{
    typedef … type;
};

class template lazy_binding

Defined in
boost/parameter/binding.hpp

A metafunction that, given an ArgumentPack, returns the reference type of the parameter identified by Keyword. If no such parameter has been specified, returns the type returned by invoking DefaultFn.

template <class Parameters, class Keyword, class DefaultFn>
struct lazy_binding
{
    typedef … type;
};

Requirements

DefaultFn is a nullary function object. The type returned by invoking this function is determined by boost::result_of<DefaultFn()>::type on compilers that support partial specialization. On less compliant compilers a nested DefaultFn::result_type is used instead.


concept KeywordExpression, KeywordDefaultExpression

Models of these concepts are used as indices in a ArgumentPack. Models of KeywordDefaultExpression will hold a default value to be used when no appropriate argument was passed.

Lazy Defaults

A KeywordDefaultExpression may contain a lazy default, meaning it's default value is only computed when needed.


concept ArgumentPack

Models of this concept are containers of parameters where each parameter is tagged with a keyword.

Requirements

  • x and z are objects that model ArgumentPack.
  • z is a ArgumentPack containing only one argument, as created by keyword::operator.
  • y is a model if KeywordExpression.
  • u is a model if KeywordDefaultExpression.
  • X is the type of x.
  • K is the tag type used in y and u.
  • D is the type of the default value in u.
Expression Type Requirements Semantics/Notes
x[y] binding<X, K>::type An argument tagged with K exists in x. Returns the bound argument tagged with K.
x[u] binding<X, K, D>::type -

Returns the bound argument tagged with K if such an argument exists. Otherwise returns the default value of u.

If u has a lazy default, this may throw whatever the default value function of u throws when x does not contain an argument tagged with K.

x, z Model of ArgumentPack - Returns a composite ArgumentPack that contains bindings to all arguments bound in x and z.

concept ParameterSpec

Used to describe type restrictions and positional meaning in a parameter set.

Models of this concept with special meaning are:

  • required
  • optional

Any other type will be treated as a keyword Tag.


macro BOOST_PARAMETER_KEYWORD

Defined in
boost/parameter/keyword.hpp

Macro used to define keyword objects.

BOOST_PARAMETER_KEYWORD(tag_namespace, name)

Requirements

  • tag_namespace is the namespace where the tag-types will be placed.
  • name is the name that will be used for the keyword.

macro BOOST_PARAMETER_FUN

Defined in
boost/parameter/macros.hpp
BOOST_PARAMETER_FUN(ret, name, lo, hi, parameters)

Requirements

  • ret is the return type of the function.
  • name is the name of the function.
  • lo, hi defines the range of arities for the function.
  • parameters is the name of the parameters<> instance used for the function.

Generated on: 2005-07-26 16:59 UTC. Generated by Docutils from reStructuredText source.