1/*=============================================================================
2 Copyright (c) 2001-2017 Joel de Guzman
3 Copyright (c) 2017 think-cell GmbH
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#include <boost/spirit/home/qi.hpp>
9
10#include <boost/core/lightweight_test.hpp>
11#include <boost/range/adaptor/transformed.hpp>
12
13#include <iostream>
14#include <string>
15#include <functional>
16
17namespace {
18 char transform_func(char c) {
19 return c < 'a' || 'z' < c ? c : static_cast<char>(c - 'a' + 'A');
20 }
21}
22
23int main()
24{
25 using boost::adaptors::transform;
26 using boost::spirit::qi::raw;
27 using boost::spirit::qi::eps;
28 using boost::spirit::qi::eoi;
29 using boost::spirit::qi::upper;
30 using boost::spirit::qi::repeat;
31 using boost::spirit::qi::parse;
32
33 std::string input = "abcde";
34 boost::transformed_range<char(*)(char), std::string> const rng = transform(rng&: input, fn: transform_func);
35
36 {
37 std::string str;
38 BOOST_TEST((parse(boost::begin(rng), boost::end(rng), +upper >> eoi, str)));
39 BOOST_TEST(("ABCDE"==str));
40 }
41
42 {
43 boost::iterator_range<boost::range_iterator<boost::transformed_range<char(*)(char), std::string> const>::type> str;
44 BOOST_TEST((parse(boost::begin(rng), boost::end(rng), raw[+upper >> eoi], str)));
45 BOOST_TEST((boost::equal(std::string("ABCDE"), str)));
46 }
47
48 {
49 BOOST_TEST((parse(boost::begin(rng), boost::end(rng), (repeat(6)[upper] | repeat(5)[upper]) >> eoi)));
50 }
51
52 return boost::report_errors();
53}
54

source code of boost/libs/spirit/test/qi/iterator_check.cpp