fc8ad948666cc687b2536bdd846d9715d0d7d4f1
[platform/upstream/boost.git] / boost / xpressive / detail / static / modifier.hpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // modifier.hpp
3 //
4 //  Copyright 2008 Eric Niebler. Distributed under the Boost
5 //  Software License, Version 1.0. (See accompanying file
6 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
10
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER)
13 # pragma once
14 # pragma warning(push)
15 # pragma warning(disable : 4510) // default constructor could not be generated
16 # pragma warning(disable : 4610) // user defined constructor required
17 #endif
18
19 #include <boost/xpressive/detail/detail_fwd.hpp>
20 #include <boost/proto/traits.hpp>
21 #include <boost/xpressive/regex_constants.hpp>
22
23 namespace boost { namespace xpressive { namespace detail
24 {
25
26     ///////////////////////////////////////////////////////////////////////////////
27     // modifier
28     template<typename Modifier>
29     struct modifier_op
30     {
31         typedef regex_constants::syntax_option_type opt_type;
32
33         template<typename Expr>
34         struct apply
35         {
36             typedef typename proto::binary_expr<
37                 modifier_tag
38               , typename proto::terminal<Modifier>::type
39               , typename proto::result_of::as_child<Expr const>::type
40             >::type type;
41         };
42
43         template<typename Expr>
44         typename apply<Expr>::type const
45         operator ()(Expr const &expr) const
46         {
47             typename apply<Expr>::type that = {{this->mod_}, proto::as_child(expr)};
48             return that;
49         }
50
51         operator opt_type() const
52         {
53             return this->opt_;
54         }
55
56         Modifier mod_;
57         opt_type opt_;
58     };
59
60 }}}
61
62 #if defined(_MSC_VER)
63 # pragma warning(pop)
64 #endif
65
66 #endif