Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Macro BOOST_PROTO_DEFINE_ENV_VAR

BOOST_PROTO_DEFINE_ENV_VAR — Define a type and a global variable of that type that can be used to initialize a slot in a Proto transform environment.

Synopsis

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

BOOST_PROTO_DEFINE_ENV_VAR(Type, Name)

Description

Proto primitive transforms can optionally accept an environment in their third parameter which is a key/value store of environment variables. Use the BOOST_PROTO_DEFINE_ENV_VAR() macro to define the keys.

See the description for proto::data_type for an example of the class interface created by this macro.

Example:

BOOST_PROTO_DEFINE_ENV_VAR(mykey_type, mykey);

struct FetchMyKey
  : proto::when< _, proto::_env_var<mykey_type> >
{};

int main()
{
    proto::terminal<int>::type i = {42};
    char const * sz = FetchMyKey()(i, 0, (mykey = "hello!"));
    assert(0 == std::strcmp(sz, "hello!");
}


PrevUpHomeNext