look_ahead.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright (c) 2001, Daniel C. Nuffer
  2. // Copyright (c) 2001-2011 Hartmut Kaiser
  3. // http://spirit.sourceforge.net/
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #if !defined(BOOST_SPIRIT_ITERATOR_LOOK_AHEAD_MAR_16_2007_1253PM)
  8. #define BOOST_SPIRIT_ITERATOR_LOOK_AHEAD_MAR_16_2007_1253PM
  9. #include <boost/spirit/home/support/iterators/detail/first_owner_policy.hpp>
  10. #include <boost/spirit/home/support/iterators/detail/no_check_policy.hpp>
  11. #include <boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp>
  12. #include <boost/spirit/home/support/iterators/detail/fixed_size_queue_policy.hpp>
  13. #include <boost/spirit/home/support/iterators/detail/combine_policies.hpp>
  14. #include <boost/spirit/home/support/iterators/multi_pass.hpp>
  15. namespace boost { namespace spirit
  16. {
  17. ///////////////////////////////////////////////////////////////////////////
  18. // this could be a template typedef, since such a thing doesn't
  19. // exist in C++, we'll use inheritance to accomplish the same thing.
  20. ///////////////////////////////////////////////////////////////////////////
  21. template <typename T, std::size_t N>
  22. class look_ahead :
  23. public multi_pass<T
  24. , iterator_policies::default_policy<
  25. iterator_policies::first_owner
  26. , iterator_policies::no_check
  27. , iterator_policies::input_iterator
  28. , iterator_policies::fixed_size_queue<N> >
  29. >
  30. {
  31. private:
  32. typedef multi_pass<T
  33. , iterator_policies::default_policy<
  34. iterator_policies::first_owner
  35. , iterator_policies::no_check
  36. , iterator_policies::input_iterator
  37. , iterator_policies::fixed_size_queue<N> >
  38. > base_type;
  39. public:
  40. look_ahead()
  41. : base_type() {}
  42. explicit look_ahead(T x)
  43. : base_type(x) {}
  44. look_ahead(look_ahead const& x)
  45. : base_type(x) {}
  46. #if BOOST_WORKAROUND(__GLIBCPP__, == 20020514)
  47. look_ahead(int) // workaround for a bug in the library
  48. : base_type() {} // shipped with gcc 3.1
  49. #endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514)
  50. look_ahead operator= (base_type const& rhs)
  51. {
  52. this->base_type::operator=(rhs);
  53. return *this;
  54. }
  55. // default generated operators destructor and assignment operator are ok.
  56. };
  57. }}
  58. #endif