1 /*=============================================================================
2 Copyright (c) 2003 Giovanni Bajo
3 Copyright (c) 2003 Martin Wille
4 http://spirit.sourceforge.net/
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
10 #include <boost/spirit/include/classic_multi_pass.hpp>
12 #include "impl/sstream.hpp"
13 #include <boost/core/lightweight_test.hpp>
16 using namespace BOOST_SPIRIT_CLASSIC_NS
;
18 // Test for bug #720917
19 // http://sf.net/tracker/index.php?func=detail&aid=720917&group_id=28447&atid=393386
21 // Check that it's possible to use multi_pass
22 // together with standard library as a normal iterator
25 // a functor to test out the functor_multi_pass
29 typedef char result_type
;
42 static result_type eof
;
47 my_functor::result_type
my_functor::eof
= '\0';
49 ////////////////////////////////////////////////
50 // four types of multi_pass iterators
53 multi_pass_policies::functor_input
,
54 multi_pass_policies::first_owner
,
55 multi_pass_policies::no_check
,
56 multi_pass_policies::std_deque
57 > functor_multi_pass_t
;
59 typedef multi_pass
<istream_iterator
<char> > default_multi_pass_t
;
60 typedef look_ahead
<istream_iterator
<char>, 6> fixed_multi_pass_t
;
63 istream_iterator
<char>,
64 multi_pass_policies::input_iterator
,
65 multi_pass_policies::first_owner
,
66 multi_pass_policies::buf_id_check
,
67 multi_pass_policies::std_deque
68 > first_owner_multi_pass_t
;
71 ////////////////////////////////////////////////
73 template <typename IterT
>
74 void construct_string_from(void)
80 istream_iterator
<char> a(ss
);
84 #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
85 dummy
.assign(mp1
, mpend
);
87 copy(mp1
, mpend
, inserter(dummy
, dummy
.end()));
92 void construct_string_from
<functor_multi_pass_t
>(void)
94 functor_multi_pass_t mpend
;
95 functor_multi_pass_t mp1
= functor_multi_pass_t(my_functor());
98 #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
99 dummy
.assign(mp1
, mpend
);
101 copy(mp1
, mpend
, inserter(dummy
, dummy
.end()));
105 ////////////////////////////////////////////////
106 // Definition of the test suite
110 construct_string_from
<default_multi_pass_t
>();
111 construct_string_from
<fixed_multi_pass_t
>();
112 construct_string_from
<first_owner_multi_pass_t
>();
113 construct_string_from
<functor_multi_pass_t
>();
114 return boost::report_errors();