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

Function operator,

boost::proto::operator, — For composing a larger transform environment from two smaller ones.

Synopsis

// In header: <boost/proto/transform/env.hpp>


template<typename Env, typename Key, typename Value> 
  proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env &>::type)> 
  operator,(Env & other, proto::env<Key, Value> const & head);
template<typename Env, typename Key, typename Value> 
  proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env const &>::type)> 
  operator,(Env const & other, proto::env<Key, Value> const & head);

Description

The effect of this function is to take two transform environments and compose them into a larger environment that contains the key/values pairs of the two. The first argument is allowed to not be a transform environment, in which case it is turned into one with the proto::as_env() function before composition with the second argument. The second argument is required to be a transform environment with exactly one key/value pair.

Example:

Given user-defined keys key0 and key1 of types key0_type and key1_type, the following code demonstrates how the chained use of operator, can build a composite transform environment containing a number of key/value pairs:

proto::env<
    key1_type
  , int
  , proto::env<
        key0_type
      , char const (&)[6]
      , proto::env<proto::data_type, int>
    >
> myenv = (proto::data = 1, key0 = "hello", key1 = 42);
// NOTE: operator, here --^    and here --^

// Check the results:
assert(1 == myenv[proto::data]);
assert(0 == std::strcmp(myenv[key0], "hello"));
assert(42 == myenv[key1]);

Note: In the return type and the "Returns" clause, UNCVREF(X) is the type X stripped of top-level reference and cv-qualifiers.

Note: In the "Returns" clause, cv is replaced with const for the second overload, and nothing for the first.

See also:

Returns:

proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env cv &>::type)>(head[Key()], proto::as_env(other))

PrevUpHomeNext