For defining a placeholder to stand in for a variable a semantic action. More...
#include <xpressive_fwd.hpp>
Public Types | |
typedef placeholder< T, I, Dummy > | this_type |
typedef proto::terminal < detail::action_arg< T, mpl::int_< I > > >::type | action_arg_type |
For defining a placeholder to stand in for a variable a semantic action.
Use placeholder<>
to define a placeholder for use in semantic actions to stand in for real objects. The use of placeholders allows regular expressions with actions to be defined once and reused in many contexts to read and write from objects which were not available when the regex was defined.
T | The type of the object for which this placeholder stands in. |
I | An optional identifier that can be used to distinguish this placeholder from others that may be used in the same semantic action that happen to have the same type. |
You can use placeholder<>
by creating an object of type placeholder<T>
and using that object in a semantic action exactly as you intend an object of type T
to be used.
Then, when doing a pattern match with either regex_search()
, regex_match()
or regex_replace()
, pass a match_results<>
object that contains bindings for the placeholders used in the regex object's semantic actions. You can create the bindings by calling match_results::let
as follows:
If a semantic action executes that contains an unbound placeholder, a exception of type regex_error
is thrown.
See the discussion for xpressive::let()
and the {user_s_guide.semantic_actions_and_user_defined_assertions.referring_to_non_local_variables, "Referring to Non-Local Variables"} section in the Users' Guide for more information.
Example:
typedef proto::terminal<detail::action_arg<T, mpl::int_<I> > >::type boost::xpressive::placeholder< T, I, Dummy >::action_arg_type |
typedef placeholder<T, I, Dummy> boost::xpressive::placeholder< T, I, Dummy >::this_type |