The type of objects returned when a key-based lookup fails in a
transform environment.
The type of an object that represents a transform environment
with no key/value pairs in it.
proto::key_not_found
unspecified
The type of the argument to this function has a
user-defined implicit conversion from any type.
proto::empty_env
Value const &
The value to be associated with the Key
.
Env const &
Env()
Another key/value store.
see-below
see-below
If called with an object that is implicitly convertible to type Key
,
this function returns the Value
passed to the constructor. Otherwise, it returns
the result of calling operator[]
on the Env
passed to
the constructor.
mpl::bool_<true-or-false>
A Boolean metafuntion for determining whether or not a type is a Proto
transform environment.
is_env<T>
inherits from mpl::true_
under the following
conditions:
If T
is proto::empty_env.
If T
is a specialization of proto::env<>.
If T
is derived from any of the above.
If T
is a cv-qualified variant of any of the above.
If T
is a reference to any of the above.
Otherwise, is_env<T>
inherits from mpl::false_
.
The type of proto::data
, a key for use when creating
a transform environment that associates a piece of data with this type.
The proto::data_type
type, along with the proto::data
global, are declared using the BOOST_PROTO_DEFINE_ENV_VAR()
macro.
env<data_type, see-below>
Value &
env<data_type, see-below>
Value const &
If Value
is a specialization boost::reference_wrapper<T>
,
this function returns env<data_type, T &>(value.get())
.
Else, if the type Value
is non-copyable (i.e., a function, an array, abstract, or an ostream),
this function returns env<data_type, Value cv &>(value)
,
where cv
is const
for the second overload, and empty
for the first.
Otherwise, this function returns env<data_type, Value>(value)
.
A key used for creating a transform environment.
proto::data_type const
proto::callable
A unary PolymorphicFunctionObject for ensuring that an object
is a transform environment. If it isn't already, it is turned into one such that the
object is associated with the proto::data_type key.
see-below
See proto::functional::as_env::operator()
.
Encodes the return type of proto::functional::as_env::operator()
.
The presence of this member template makes proto::functional::as_env
a valid TR1-style function object type usable with boost::result_of<>
.
see-below
T &
see-below
T const &
If proto::is_env<T>::value
is false
,
this function returns the result of (proto::data = t)
.
See proto::data_type::operator=
for details.
Otherwise, this function returns t
by reference.
proto::callable
A unary boolean PolymorphicFunctionObject used for determining whether a particular
transform environment has a value associated with a particular key.
see-below
See proto::functional::has_env_var::operator()
.
Encodes the return type of proto::functional::has_env_var::operator()
.
The presence of this member template makes proto::functional::has_env_var
a valid TR1-style function object type usable with boost::result_of<>
.
see-below
Env const &
This function behaves as follows:
If proto::is_env<Env>::value
is true
:
If e[Key()]
returns an instance of
proto::key_not_found
, return
mpl::false_
. See proto::env::operator[]
for more information.
Otherwise, return mpl::true_
.
Otherwise:
If Key
is proto::data_type
,
return mpl::true_
.
Otherwise, return mpl::false_
.
proto::callable
A unary PolymorphicFunctionObject used for fetching the value
associated with a particular key in a transform environment.
see-below
See proto::functional::env_var::operator()
.
Encodes the return type of proto::functional::env_var::operator()
.
The presence of this member template makes proto::functional::env_var
a valid TR1-style function object type usable with boost::result_of<>
.
see-below
Env const &
This function behaves as follows:
If Key
is proto::data_type
:
If proto::is_env<Env>::value
is true
,
return e[proto::data]
.
Otherwise, return e
.
Otherwise, return e[Key()]
.
See proto::env::operator[]
for additional information.
boost::result_of<proto::functional::as_env(T)>
Metafunction for computing the return type of proto::as_env()
.
boost::result_of<proto::functional::has_env_var<Key>(Env)>::type
Metafunction for computing the return type of proto::has_env_var()
.
boost::result_of<proto::functional::env_var<Key>(Env)>
Metafunction for computing the return type of proto::env_var()
.
typename proto::result_of::as_env<T &>::type
T &
typename proto::result_of::as_env<T const &>::type
T const &
For ensuring that the given argument is a transform environment. If it is not already,
it is made one as if by (proto::data = t)
.
See also:
proto::data_type::operator=
proto::functional::as_env::operator()
proto::functional::as_env()(t)
typename proto::result_of::has_env_var<Env &, Key>::type
Env &
typename proto::result_of::has_env_var<Env const &, Key>::type
Env const &
For testing to see whether a value exists in a transform environment corresponding to the
specified Key
.
See also:
proto::functional::has_env_var::operator()
proto::functional::has_env_var<Key>()(e)
typename proto::result_of::env_var<Env &, Key>::type
Env &
typename proto::result_of::env_var<Env const &, Key>::type
Env const &
For fetching the value from a transform environment corresponding to the
specified Key
.
See also:
proto::functional::env_var::operator()
proto::functional::env_var<Key>()(e)
proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env &>::type)>
Env &
proto::env<Key, Value> const &
proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env const &>::type)>
Env const &
proto::env<Key, Value> const &
For composing a larger transform environment from two smaller ones.
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:
proto::env::operator[]
proto::env<Key, Value, UNCVREF(typename proto::result_of::as_env<Env cv &>::type)>(head[Key()], proto::as_env(other))
A primitive transform that returns the value associated with a particular Key
in the current transform environment.
proto::transform<_env_var<Key> >
proto::transform_impl<Expr, State, Data> >
typename proto::result_of::env_var<Data, Key>::type
result_type
typename impl::expr_param
typename impl::state_param
typename impl::data_param
The current transform environment
Fetches the value associated with Key
from the transform environment
passed in the data (third) parameter.
proto::is_env<Data>::value
is true
.
proto::env_var(data)
See proto::_env_var::impl
for the full details.
A primitive transform that returns the current transform environment unmodified.
proto::transform<_env>
proto::transform_impl<Expr, State, Data>
Data
result_type
typename impl::expr_param
typename impl::state_param
typename impl::data_param
The current transform environment
Returns the current transform environment
passed in the data (third) parameter.
data
See proto::_env::impl
for the full details.
Define a type and a global variable of that type that can be used
to initialize a slot in a Proto transform environment.
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!");
}