Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / spirit / home / x3 / operator / and_predicate.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2014 Joel de Guzman
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 #if !defined(SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM)
8 #define SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM
9
10 #if defined(_MSC_VER)
11 #pragma once
12 #endif
13
14 #include <boost/spirit/home/x3/core/parser.hpp>
15
16 namespace boost { namespace spirit { namespace x3
17 {
18     template <typename Subject>
19     struct and_predicate : unary_parser<Subject, and_predicate<Subject>>
20     {
21         typedef unary_parser<Subject, and_predicate<Subject>> base_type;
22
23         typedef unused_type attribute_type;
24         static bool const has_attribute = false;
25
26         and_predicate(Subject const& subject)
27           : base_type(subject) {}
28
29         template <typename Iterator, typename Context
30           , typename RContext, typename Attribute>
31         bool parse(Iterator& first, Iterator const& last
32           , Context const& context, RContext& rcontext, Attribute& /*attr*/) const
33         {
34             Iterator i = first;
35             return this->subject.parse(i, last, context, rcontext, unused);
36         }
37     };
38
39     template <typename Subject>
40     inline and_predicate<typename extension::as_parser<Subject>::value_type>
41     operator&(Subject const& subject)
42     {
43         return {as_parser(subject)};
44     }
45 }}}
46
47 #endif