unused_skipper.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #if !defined(BOOST_SPIRIT_QI_UNUSED_SKIPPER_JUL_25_2009_0921AM)
  6. #define BOOST_SPIRIT_QI_UNUSED_SKIPPER_JUL_25_2009_0921AM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/support/unused.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. namespace boost { namespace spirit { namespace qi { namespace detail
  13. {
  14. #ifdef _MSC_VER
  15. # pragma warning(push)
  16. # pragma warning(disable: 4512) // assignment operator could not be generated.
  17. #endif
  18. template <typename Skipper>
  19. struct unused_skipper : unused_type
  20. {
  21. unused_skipper(Skipper const& skipper_)
  22. : skipper(skipper_) {}
  23. Skipper const& skipper;
  24. };
  25. #ifdef _MSC_VER
  26. # pragma warning(pop)
  27. #endif
  28. template <typename Skipper>
  29. struct is_unused_skipper
  30. : mpl::false_ {};
  31. template <typename Skipper>
  32. struct is_unused_skipper<unused_skipper<Skipper> >
  33. : mpl::true_ {};
  34. template <>
  35. struct is_unused_skipper<unused_type>
  36. : mpl::true_ {};
  37. // If a surrounding lexeme[] directive was specified, the current
  38. // skipper is of the type unused_skipper. In this case we
  39. // re-activate the skipper which was active before the skip[]
  40. // directive.
  41. template <typename Skipper>
  42. inline Skipper const&
  43. get_skipper(unused_skipper<Skipper> const& u)
  44. {
  45. return u.skipper;
  46. }
  47. // If no surrounding lexeme[] directive was specified we keep what we got.
  48. template <typename Skipper>
  49. inline Skipper const&
  50. get_skipper(Skipper const& u)
  51. {
  52. return u;
  53. }
  54. }}}}
  55. #endif