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 8 #if !defined(BOOST_SPIRIT_ITERATOR_LOOK_AHEAD_MAR_16_2007_1253PM) 9 #define BOOST_SPIRIT_ITERATOR_LOOK_AHEAD_MAR_16_2007_1253PM 10 11 #include <boost/spirit/home/support/iterators/detail/first_owner_policy.hpp> 12 #include <boost/spirit/home/support/iterators/detail/no_check_policy.hpp> 13 #include <boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp> 14 #include <boost/spirit/home/support/iterators/detail/fixed_size_queue_policy.hpp> 15 #include <boost/spirit/home/support/iterators/detail/combine_policies.hpp> 16 #include <boost/spirit/home/support/iterators/multi_pass.hpp> 17 18 namespace boost { namespace spirit 19 { 20 /////////////////////////////////////////////////////////////////////////// 21 // this could be a template typedef, since such a thing doesn't 22 // exist in C++, we'll use inheritance to accomplish the same thing. 23 /////////////////////////////////////////////////////////////////////////// 24 template <typename T, std::size_t N> 25 class look_ahead : 26 public multi_pass<T 27 , iterator_policies::default_policy< 28 iterator_policies::first_owner 29 , iterator_policies::no_check 30 , iterator_policies::input_iterator 31 , iterator_policies::fixed_size_queue<N> > 32 > 33 { 34 private: 35 typedef multi_pass<T 36 , iterator_policies::default_policy< 37 iterator_policies::first_owner 38 , iterator_policies::no_check 39 , iterator_policies::input_iterator 40 , iterator_policies::fixed_size_queue<N> > 41 > base_type; 42 43 public: look_ahead()44 look_ahead() 45 : base_type() {} 46 look_ahead(T x)47 explicit look_ahead(T x) 48 : base_type(x) {} 49 look_ahead(look_ahead const & x)50 look_ahead(look_ahead const& x) 51 : base_type(x) {} 52 53 #if BOOST_WORKAROUND(__GLIBCPP__, == 20020514) look_ahead(int)54 look_ahead(int) // workaround for a bug in the library 55 : base_type() {} // shipped with gcc 3.1 56 #endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514) 57 operator =(base_type const & rhs)58 look_ahead operator= (base_type const& rhs) 59 { 60 this->base_type::operator=(rhs); 61 return *this; 62 } 63 64 // default generated operators destructor and assignment operator are ok. 65 }; 66 67 }} 68 69 #endif 70