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 to view this page for the latest version.
PrevUpHomeNext

Macro BOOST_PROTO_BASIC_EXTENDS

BOOST_PROTO_BASIC_EXTENDS — For creating expression wrappers that add members to a Proto expression template, like proto::extends<>, but while retaining POD-ness of the expression wrapper.

Synopsis

// In header: <boost/proto/extends.hpp>

BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain)

Description

BOOST_PROTO_BASIC_EXTENDS() adds the basic typedefs, member functions, and data members necessary to make a struct a valid Proto expression extension. It does not add any constructors, virtual functions or access control blocks that would render the containing struct non-POD.

Expr is the Proto expression that the enclosing struct extends. Derived is the type of the enclosing struct. Domain is the Proto domain to which this expression extension belongs. (See proto::domain<>.) Can be preceeded with "typename" if the specified domain is a dependent type.

BOOST_PROTO_BASIC_EXTENDS() adds to its enclosing struct exactly one data member of type Expr.

If the Domain parameter is dependent, you can specify it as typename Domain, as in BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, typename Domain)

Example:

template< class Expr >
struct my_expr;

struct my_domain
  : proto::domain< proto::pod_generator< my_expr > >
{};

template< class Expr >
struct my_expr
{
    // OK, this makes my_expr<> a valid Proto expression extension.
    // my_expr<> does /not/ have overloaded assignment, subscript,
    // and function call operators that build expression templates, however.
    BOOST_PROTO_BASIC_EXTENDS(Expr, my_expr, my_domain)
};

// OK, my_expr<> is POD, so this is statically initialized:
my_expr< proto::terminal<int>::type > const _1 = {{1}};

See also:


PrevUpHomeNext