1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
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(BOOST_SPIRIT_X3_REAL_APRIL_18_2006_0850AM)
8 #define BOOST_SPIRIT_X3_REAL_APRIL_18_2006_0850AM
10 #include <boost/spirit/home/x3/core/parser.hpp>
11 #include <boost/spirit/home/x3/core/skip_over.hpp>
12 #include <boost/spirit/home/x3/numeric/real_policies.hpp>
13 #include <boost/spirit/home/x3/support/numeric_utils/extract_real.hpp>
15 namespace boost { namespace spirit { namespace x3
17 template <typename T, typename RealPolicies = real_policies<T> >
18 struct real_parser : parser<real_parser<T, RealPolicies> >
20 typedef T attribute_type;
21 static bool const has_attribute = true;
26 real_parser(RealPolicies const& policies)
27 : policies(policies) {}
29 template <typename Iterator, typename Context>
30 bool parse(Iterator& first, Iterator const& last
31 , Context const& context, unused_type, T& attr_) const
33 x3::skip_over(first, last, context);
34 return extract_real<T, RealPolicies>::parse(first, last, attr_, policies);
37 template <typename Iterator, typename Context, typename Attribute>
38 bool parse(Iterator& first, Iterator const& last
39 , Context const& context, unused_type, Attribute& attr_param) const
41 // this case is called when Attribute is not T
43 if (parse(first, last, context, unused, attr_))
45 traits::move_to(attr_, attr_param);
51 RealPolicies policies;
54 typedef real_parser<float> float_type;
55 float_type const float_ = {};
57 typedef real_parser<double> double_type;
58 double_type const double_ = {};