• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef META_HS_EXCEPT_KEYWORDS_HPP
2 #define META_HS_EXCEPT_KEYWORDS_HPP
3 
4 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2012.
5 // Distributed under the Boost Software License, Version 1.0.
6 //    (See accompanying file LICENSE_1_0.txt or copy at
7 //          http://www.boost.org/LICENSE_1_0.txt)
8 
9 #include <boost/metaparse/accept_when.hpp>
10 
11 #include <boost/mpl/equal.hpp>
12 #include <boost/mpl/and.hpp>
13 #include <boost/mpl/not.hpp>
14 #include <boost/mpl/fold.hpp>
15 #include <boost/mpl/bool.hpp>
16 #include <boost/mpl/apply_wrap.hpp>
17 
18 struct keywords_are_not_allowed {};
19 
20 template <class P, class Keywords>
21 class except_keywords
22 {
23 private:
24   template <class T>
25   struct not_a_keyword
26   {
27     typedef not_a_keyword type;
28 
29     template <class Acc, class Keyword>
30     struct apply :
31       boost::mpl::and_<
32         Acc,
33         boost::mpl::not_<typename boost::mpl::equal<T, Keyword>::type>
34       >
35     {};
36   };
37 
38   struct not_keyword
39   {
40     typedef not_keyword type;
41 
42     template <class T>
43     struct apply :
44       boost::mpl::fold<Keywords, boost::mpl::true_, not_a_keyword<T> >
45     {};
46   };
47 public:
48   typedef except_keywords type;
49 
50   template <class S, class Pos>
51   struct apply :
52     boost::mpl::apply_wrap2<
53       boost::metaparse::accept_when<P, not_keyword, keywords_are_not_allowed>,
54       S,
55       Pos
56     >
57   {};
58 };
59 
60 #endif
61 
62