• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2011 Hartmut Kaiser
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 
8 #include <boost/config/warning_disable.hpp>
9 
10 #include <boost/spirit/include/karma_operator.hpp>
11 #include <boost/spirit/include/karma_char.hpp>
12 #include <boost/spirit/include/karma_string.hpp>
13 #include <boost/spirit/include/karma_numeric.hpp>
14 #include <boost/spirit/include/karma_nonterminal.hpp>
15 #include <boost/spirit/include/karma_generate.hpp>
16 
17 #include "test.hpp"
18 
19 using namespace boost::spirit;
20 using namespace boost::spirit::ascii;
21 
22 typedef spirit_test::output_iterator<char>::type outiter_type;
23 
24 struct num_list : karma::grammar<outiter_type, karma::rule<outiter_type> >
25 {
num_listnum_list26     num_list() : num_list::base_type(start)
27     {
28         start = int_(1) << ',' << int_(0);
29     }
30 
31     karma::rule<outiter_type, karma::rule<outiter_type> > start;
32 };
33 
34 // this test must fail compiling as the rule is used with an incompatible
35 // delimiter type
main()36 int main()
37 {
38     std::string generated;
39 
40     std::back_insert_iterator<std::string> outit(generated);
41     num_list def;
42     generate_delimited(outit, def, char_('%') << '\n');
43 
44     return 0;
45 }
46