modifier.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
  8. #define BOOST_XPRESSIVE_DETAIL_STATIC_MODIFIER_HPP_EAN_10_04_2005
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. # pragma warning(push)
  13. # pragma warning(disable : 4510) // default constructor could not be generated
  14. # pragma warning(disable : 4610) // user defined constructor required
  15. #endif
  16. #include <boost/xpressive/detail/detail_fwd.hpp>
  17. #include <boost/proto/traits.hpp>
  18. #include <boost/xpressive/regex_constants.hpp>
  19. namespace boost { namespace xpressive { namespace detail
  20. {
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // modifier
  23. template<typename Modifier>
  24. struct modifier_op
  25. {
  26. typedef regex_constants::syntax_option_type opt_type;
  27. template<typename Expr>
  28. struct apply
  29. {
  30. typedef typename proto::binary_expr<
  31. modifier_tag
  32. , typename proto::terminal<Modifier>::type
  33. , typename proto::result_of::as_child<Expr const>::type
  34. >::type type;
  35. };
  36. template<typename Expr>
  37. typename apply<Expr>::type const
  38. operator ()(Expr const &expr) const
  39. {
  40. typename apply<Expr>::type that = {{this->mod_}, proto::as_child(expr)};
  41. return that;
  42. }
  43. operator opt_type() const
  44. {
  45. return this->opt_;
  46. }
  47. Modifier mod_;
  48. opt_type opt_;
  49. };
  50. }}}
  51. #if defined(_MSC_VER)
  52. # pragma warning(pop)
  53. #endif
  54. #endif