Chris@16
|
1 // Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@16
|
2 //
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #if !defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)
|
Chris@16
|
7 #define BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM
|
Chris@16
|
8
|
Chris@16
|
9 #if defined(_MSC_VER)
|
Chris@16
|
10 #pragma once
|
Chris@16
|
11 #endif
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/config/no_tr1/cmath.hpp>
|
Chris@16
|
14 #include <boost/config.hpp>
|
Chris@16
|
15 #include <boost/mpl/bool.hpp>
|
Chris@16
|
16 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
17 #include <boost/spirit/home/support/common_terminals.hpp>
|
Chris@16
|
18 #include <boost/spirit/home/support/string_traits.hpp>
|
Chris@16
|
19 #include <boost/spirit/home/support/numeric_traits.hpp>
|
Chris@16
|
20 #include <boost/spirit/home/support/info.hpp>
|
Chris@16
|
21 #include <boost/spirit/home/support/char_class.hpp>
|
Chris@16
|
22 #include <boost/spirit/home/support/container.hpp>
|
Chris@16
|
23 #include <boost/spirit/home/support/detail/get_encoding.hpp>
|
Chris@16
|
24 #include <boost/spirit/home/karma/meta_compiler.hpp>
|
Chris@16
|
25 #include <boost/spirit/home/karma/char.hpp>
|
Chris@16
|
26 #include <boost/spirit/home/karma/delimit_out.hpp>
|
Chris@16
|
27 #include <boost/spirit/home/karma/auxiliary/lazy.hpp>
|
Chris@16
|
28 #include <boost/spirit/home/karma/detail/get_casetag.hpp>
|
Chris@16
|
29 #include <boost/spirit/home/karma/detail/extract_from.hpp>
|
Chris@16
|
30 #include <boost/spirit/home/karma/detail/enable_lit.hpp>
|
Chris@16
|
31 #include <boost/spirit/home/karma/domain.hpp>
|
Chris@16
|
32 #include <boost/spirit/home/karma/numeric/real_policies.hpp>
|
Chris@16
|
33 #include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
|
Chris@16
|
34 #include <boost/fusion/include/at.hpp>
|
Chris@16
|
35 #include <boost/fusion/include/value_at.hpp>
|
Chris@16
|
36 #include <boost/fusion/include/vector.hpp>
|
Chris@16
|
37
|
Chris@16
|
38 namespace boost { namespace spirit
|
Chris@16
|
39 {
|
Chris@16
|
40 namespace karma
|
Chris@16
|
41 {
|
Chris@16
|
42 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
43 // forward declaration only
|
Chris@16
|
44 template <typename T>
|
Chris@16
|
45 struct real_policies;
|
Chris@16
|
46
|
Chris@16
|
47 ///////////////////////////////////////////////////////////////////////
|
Chris@16
|
48 // This is the class that the user can instantiate directly in
|
Chris@16
|
49 // order to create a customized real generator
|
Chris@16
|
50 template <typename T = double, typename Policies = real_policies<T> >
|
Chris@16
|
51 struct real_generator
|
Chris@16
|
52 : spirit::terminal<tag::stateful_tag<Policies, tag::double_, T> >
|
Chris@16
|
53 {
|
Chris@16
|
54 typedef tag::stateful_tag<Policies, tag::double_, T> tag_type;
|
Chris@16
|
55
|
Chris@16
|
56 real_generator() {}
|
Chris@16
|
57 real_generator(Policies const& p)
|
Chris@16
|
58 : spirit::terminal<tag_type>(p) {}
|
Chris@16
|
59 };
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
63 // Enablers
|
Chris@16
|
64 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
65 template <>
|
Chris@16
|
66 struct use_terminal<karma::domain, tag::float_> // enables float_
|
Chris@16
|
67 : mpl::true_ {};
|
Chris@16
|
68
|
Chris@16
|
69 template <>
|
Chris@16
|
70 struct use_terminal<karma::domain, tag::double_> // enables double_
|
Chris@16
|
71 : mpl::true_ {};
|
Chris@16
|
72
|
Chris@16
|
73 template <>
|
Chris@16
|
74 struct use_terminal<karma::domain, tag::long_double> // enables long_double
|
Chris@16
|
75 : mpl::true_ {};
|
Chris@16
|
76
|
Chris@16
|
77 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
78 template <>
|
Chris@16
|
79 struct use_terminal<karma::domain, float> // enables lit(1.0f)
|
Chris@16
|
80 : mpl::true_ {};
|
Chris@16
|
81
|
Chris@16
|
82 template <>
|
Chris@16
|
83 struct use_terminal<karma::domain, double> // enables lit(1.0)
|
Chris@16
|
84 : mpl::true_ {};
|
Chris@16
|
85
|
Chris@16
|
86 template <>
|
Chris@16
|
87 struct use_terminal<karma::domain, long double> // enables lit(1.0l)
|
Chris@16
|
88 : mpl::true_ {};
|
Chris@16
|
89
|
Chris@16
|
90 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
91 template <typename A0>
|
Chris@16
|
92 struct use_terminal<karma::domain // enables float_(...)
|
Chris@16
|
93 , terminal_ex<tag::float_, fusion::vector1<A0> >
|
Chris@16
|
94 > : mpl::true_ {};
|
Chris@16
|
95
|
Chris@16
|
96 template <typename A0>
|
Chris@16
|
97 struct use_terminal<karma::domain // enables double_(...)
|
Chris@16
|
98 , terminal_ex<tag::double_, fusion::vector1<A0> >
|
Chris@16
|
99 > : mpl::true_ {};
|
Chris@16
|
100
|
Chris@16
|
101 template <typename A0>
|
Chris@16
|
102 struct use_terminal<karma::domain // enables long_double(...)
|
Chris@16
|
103 , terminal_ex<tag::long_double, fusion::vector1<A0> >
|
Chris@16
|
104 > : mpl::true_ {};
|
Chris@16
|
105
|
Chris@16
|
106 // lazy float_(...), double_(...), long_double(...)
|
Chris@16
|
107 template <>
|
Chris@16
|
108 struct use_lazy_terminal<karma::domain, tag::float_, 1>
|
Chris@16
|
109 : mpl::true_ {};
|
Chris@16
|
110
|
Chris@16
|
111 template <>
|
Chris@16
|
112 struct use_lazy_terminal<karma::domain, tag::double_, 1>
|
Chris@16
|
113 : mpl::true_ {};
|
Chris@16
|
114
|
Chris@16
|
115 template <>
|
Chris@16
|
116 struct use_lazy_terminal<karma::domain, tag::long_double, 1>
|
Chris@16
|
117 : mpl::true_ {};
|
Chris@16
|
118
|
Chris@16
|
119 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
120 // enables custom real generator
|
Chris@16
|
121 template <typename T, typename Policies>
|
Chris@16
|
122 struct use_terminal<karma::domain
|
Chris@16
|
123 , tag::stateful_tag<Policies, tag::double_, T> >
|
Chris@16
|
124 : mpl::true_ {};
|
Chris@16
|
125
|
Chris@16
|
126 template <typename T, typename Policies, typename A0>
|
Chris@16
|
127 struct use_terminal<karma::domain
|
Chris@16
|
128 , terminal_ex<tag::stateful_tag<Policies, tag::double_, T>
|
Chris@16
|
129 , fusion::vector1<A0> > >
|
Chris@16
|
130 : mpl::true_ {};
|
Chris@16
|
131
|
Chris@16
|
132 // enables *lazy* custom real generator
|
Chris@16
|
133 template <typename T, typename Policies>
|
Chris@16
|
134 struct use_lazy_terminal<
|
Chris@16
|
135 karma::domain
|
Chris@16
|
136 , tag::stateful_tag<Policies, tag::double_, T>
|
Chris@16
|
137 , 1 // arity
|
Chris@16
|
138 > : mpl::true_ {};
|
Chris@16
|
139
|
Chris@16
|
140 // enables lit(double)
|
Chris@16
|
141 template <typename A0>
|
Chris@16
|
142 struct use_terminal<karma::domain
|
Chris@16
|
143 , terminal_ex<tag::lit, fusion::vector1<A0> >
|
Chris@16
|
144 , typename enable_if<traits::is_real<A0> >::type>
|
Chris@16
|
145 : mpl::true_ {};
|
Chris@16
|
146 }}
|
Chris@16
|
147
|
Chris@16
|
148 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
149 namespace boost { namespace spirit { namespace karma
|
Chris@16
|
150 {
|
Chris@16
|
151 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
Chris@16
|
152 using spirit::float_;
|
Chris@16
|
153 using spirit::double_;
|
Chris@16
|
154 using spirit::long_double;
|
Chris@16
|
155 #endif
|
Chris@16
|
156
|
Chris@16
|
157 using spirit::float_type;
|
Chris@16
|
158 using spirit::double_type;
|
Chris@16
|
159 using spirit::long_double_type;
|
Chris@16
|
160
|
Chris@16
|
161 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
162 // This specialization is used for real generators not having a direct
|
Chris@16
|
163 // initializer: float_, double_ etc. These generators must be used in
|
Chris@16
|
164 // conjunction with an attribute.
|
Chris@16
|
165 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
166 template <
|
Chris@16
|
167 typename T, typename Policies, typename CharEncoding, typename Tag>
|
Chris@16
|
168 struct any_real_generator
|
Chris@16
|
169 : primitive_generator<any_real_generator<T, Policies, CharEncoding, Tag> >
|
Chris@16
|
170 {
|
Chris@16
|
171 typedef typename Policies::properties properties;
|
Chris@16
|
172
|
Chris@16
|
173 template <typename Context, typename Unused>
|
Chris@16
|
174 struct attribute
|
Chris@16
|
175 {
|
Chris@16
|
176 typedef T type;
|
Chris@16
|
177 };
|
Chris@16
|
178
|
Chris@16
|
179 any_real_generator(Policies const& policies = Policies())
|
Chris@16
|
180 : p_(policies) {}
|
Chris@16
|
181
|
Chris@16
|
182 // double_/float_/etc. has an attached attribute
|
Chris@16
|
183 template <typename OutputIterator, typename Context, typename Delimiter
|
Chris@16
|
184 , typename Attribute>
|
Chris@16
|
185 bool generate(OutputIterator& sink, Context& context
|
Chris@16
|
186 , Delimiter const& d, Attribute const& attr) const
|
Chris@16
|
187 {
|
Chris@16
|
188 if (!traits::has_optional_value(attr))
|
Chris@16
|
189 return false; // fail if it's an uninitialized optional
|
Chris@16
|
190
|
Chris@16
|
191 typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
|
Chris@16
|
192 return inserter_type::call(sink, traits::extract_from<T>(attr, context), p_) &&
|
Chris@16
|
193 karma::delimit_out(sink, d); // always do post-delimiting
|
Chris@16
|
194 }
|
Chris@16
|
195
|
Chris@16
|
196 // this double_/float_/etc. has no attribute attached, it needs to have
|
Chris@16
|
197 // been initialized from a direct literal
|
Chris@16
|
198 template <typename OutputIterator, typename Context, typename Delimiter>
|
Chris@16
|
199 static bool generate(OutputIterator&, Context&, Delimiter const&
|
Chris@16
|
200 , unused_type)
|
Chris@16
|
201 {
|
Chris@16
|
202 // It is not possible (doesn't make sense) to use numeric generators
|
Chris@16
|
203 // without providing any attribute, as the generator doesn't 'know'
|
Chris@16
|
204 // what to output. The following assertion fires if this situation
|
Chris@16
|
205 // is detected in your code.
|
Chris@16
|
206 BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, real_not_usable_without_attribute, ());
|
Chris@16
|
207 return false;
|
Chris@16
|
208 }
|
Chris@16
|
209
|
Chris@16
|
210 template <typename Context>
|
Chris@16
|
211 static info what(Context const& /*context*/)
|
Chris@16
|
212 {
|
Chris@16
|
213 return info("real");
|
Chris@16
|
214 }
|
Chris@16
|
215
|
Chris@16
|
216 Policies p_;
|
Chris@16
|
217 };
|
Chris@16
|
218
|
Chris@16
|
219 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
220 // This specialization is used for real generators having a direct
|
Chris@16
|
221 // initializer: float_(10.), double_(20.) etc.
|
Chris@16
|
222 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
223 template <
|
Chris@16
|
224 typename T, typename Policies, typename CharEncoding, typename Tag
|
Chris@16
|
225 , bool no_attribute>
|
Chris@16
|
226 struct literal_real_generator
|
Chris@16
|
227 : primitive_generator<literal_real_generator<T, Policies, CharEncoding
|
Chris@16
|
228 , Tag, no_attribute> >
|
Chris@16
|
229 {
|
Chris@16
|
230 typedef typename Policies::properties properties;
|
Chris@16
|
231
|
Chris@16
|
232 template <typename Context, typename Unused = unused_type>
|
Chris@16
|
233 struct attribute
|
Chris@16
|
234 : mpl::if_c<no_attribute, unused_type, T>
|
Chris@16
|
235 {};
|
Chris@16
|
236
|
Chris@16
|
237 literal_real_generator(typename add_const<T>::type n
|
Chris@16
|
238 , Policies const& policies = Policies())
|
Chris@16
|
239 : n_(n), p_(policies) {}
|
Chris@16
|
240
|
Chris@16
|
241 // A double_(1.0) which additionally has an associated attribute emits
|
Chris@16
|
242 // its immediate literal only if it matches the attribute, otherwise
|
Chris@16
|
243 // it fails.
|
Chris@16
|
244 template <typename OutputIterator, typename Context, typename Delimiter
|
Chris@16
|
245 , typename Attribute>
|
Chris@16
|
246 bool generate(OutputIterator& sink, Context& context
|
Chris@16
|
247 , Delimiter const& d, Attribute const& attr) const
|
Chris@16
|
248 {
|
Chris@16
|
249 typedef typename attribute<Context>::type attribute_type;
|
Chris@16
|
250 if (!traits::has_optional_value(attr) ||
|
Chris@16
|
251 n_ != traits::extract_from<attribute_type>(attr, context))
|
Chris@16
|
252 {
|
Chris@16
|
253 return false;
|
Chris@16
|
254 }
|
Chris@16
|
255
|
Chris@16
|
256 typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
|
Chris@16
|
257 return inserter_type::call(sink, n_, p_) &&
|
Chris@16
|
258 karma::delimit_out(sink, d); // always do post-delimiting
|
Chris@16
|
259 }
|
Chris@16
|
260
|
Chris@16
|
261 // A double_(1.0) without any associated attribute just emits its
|
Chris@16
|
262 // immediate literal
|
Chris@16
|
263 template <typename OutputIterator, typename Context, typename Delimiter>
|
Chris@16
|
264 bool generate(OutputIterator& sink, Context&, Delimiter const& d
|
Chris@16
|
265 , unused_type) const
|
Chris@16
|
266 {
|
Chris@16
|
267 typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
|
Chris@16
|
268 return inserter_type::call(sink, n_, p_) &&
|
Chris@16
|
269 karma::delimit_out(sink, d); // always do post-delimiting
|
Chris@16
|
270 }
|
Chris@16
|
271
|
Chris@16
|
272 template <typename Context>
|
Chris@16
|
273 static info what(Context const& /*context*/)
|
Chris@16
|
274 {
|
Chris@16
|
275 return info("real");
|
Chris@16
|
276 }
|
Chris@16
|
277
|
Chris@16
|
278 T n_;
|
Chris@16
|
279 Policies p_;
|
Chris@16
|
280 };
|
Chris@16
|
281
|
Chris@16
|
282 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
283 // Generator generators: make_xxx function (objects)
|
Chris@16
|
284 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
285 namespace detail
|
Chris@16
|
286 {
|
Chris@16
|
287 template <typename T, typename Modifiers
|
Chris@16
|
288 , typename Policies = real_policies<T> >
|
Chris@16
|
289 struct make_real
|
Chris@16
|
290 {
|
Chris@16
|
291 static bool const lower =
|
Chris@16
|
292 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
|
Chris@16
|
293 static bool const upper =
|
Chris@16
|
294 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
|
Chris@16
|
295
|
Chris@16
|
296 typedef any_real_generator<
|
Chris@16
|
297 T, Policies
|
Chris@16
|
298 , typename spirit::detail::get_encoding_with_case<
|
Chris@16
|
299 Modifiers, unused_type, lower || upper>::type
|
Chris@16
|
300 , typename detail::get_casetag<Modifiers, lower || upper>::type
|
Chris@16
|
301 > result_type;
|
Chris@16
|
302
|
Chris@16
|
303 template <typename Terminal>
|
Chris@16
|
304 result_type operator()(Terminal const& term, unused_type) const
|
Chris@16
|
305 {
|
Chris@16
|
306 typedef tag::stateful_tag<Policies, tag::double_, T> tag_type;
|
Chris@16
|
307 using spirit::detail::get_stateful_data;
|
Chris@16
|
308 return result_type(get_stateful_data<tag_type>::call(term));
|
Chris@16
|
309 }
|
Chris@16
|
310 };
|
Chris@16
|
311 }
|
Chris@16
|
312
|
Chris@16
|
313 template <typename Modifiers>
|
Chris@16
|
314 struct make_primitive<tag::float_, Modifiers>
|
Chris@16
|
315 : detail::make_real<float, Modifiers> {};
|
Chris@16
|
316
|
Chris@16
|
317 template <typename Modifiers>
|
Chris@16
|
318 struct make_primitive<tag::double_, Modifiers>
|
Chris@16
|
319 : detail::make_real<double, Modifiers> {};
|
Chris@16
|
320
|
Chris@16
|
321 template <typename Modifiers>
|
Chris@16
|
322 struct make_primitive<tag::long_double, Modifiers>
|
Chris@16
|
323 : detail::make_real<long double, Modifiers> {};
|
Chris@16
|
324
|
Chris@16
|
325 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
326 template <typename T, typename Policies, typename Modifiers>
|
Chris@16
|
327 struct make_primitive<
|
Chris@16
|
328 tag::stateful_tag<Policies, tag::double_, T>, Modifiers>
|
Chris@16
|
329 : detail::make_real<typename remove_const<T>::type
|
Chris@16
|
330 , Modifiers, Policies> {};
|
Chris@16
|
331
|
Chris@16
|
332 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
333 namespace detail
|
Chris@16
|
334 {
|
Chris@16
|
335 template <typename T, typename Modifiers
|
Chris@16
|
336 , typename Policies = real_policies<T> >
|
Chris@16
|
337 struct make_real_direct
|
Chris@16
|
338 {
|
Chris@16
|
339 static bool const lower =
|
Chris@16
|
340 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
|
Chris@16
|
341 static bool const upper =
|
Chris@16
|
342 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
|
Chris@16
|
343
|
Chris@16
|
344 typedef literal_real_generator<
|
Chris@16
|
345 T, Policies
|
Chris@16
|
346 , typename spirit::detail::get_encoding_with_case<
|
Chris@16
|
347 Modifiers, unused_type, lower || upper>::type
|
Chris@16
|
348 , typename detail::get_casetag<Modifiers, lower || upper>::type
|
Chris@16
|
349 , false
|
Chris@16
|
350 > result_type;
|
Chris@16
|
351
|
Chris@16
|
352 template <typename Terminal>
|
Chris@16
|
353 result_type operator()(Terminal const& term, unused_type) const
|
Chris@16
|
354 {
|
Chris@16
|
355 typedef tag::stateful_tag<Policies, tag::double_, T> tag_type;
|
Chris@16
|
356 using spirit::detail::get_stateful_data;
|
Chris@16
|
357 return result_type(T(fusion::at_c<0>(term.args))
|
Chris@16
|
358 , get_stateful_data<tag_type>::call(term.term));
|
Chris@16
|
359 }
|
Chris@16
|
360 };
|
Chris@16
|
361 }
|
Chris@16
|
362
|
Chris@16
|
363 template <typename Modifiers, typename A0>
|
Chris@16
|
364 struct make_primitive<
|
Chris@16
|
365 terminal_ex<tag::float_, fusion::vector1<A0> >, Modifiers>
|
Chris@16
|
366 : detail::make_real_direct<float, Modifiers> {};
|
Chris@16
|
367
|
Chris@16
|
368 template <typename Modifiers, typename A0>
|
Chris@16
|
369 struct make_primitive<
|
Chris@16
|
370 terminal_ex<tag::double_, fusion::vector1<A0> >, Modifiers>
|
Chris@16
|
371 : detail::make_real_direct<double, Modifiers> {};
|
Chris@16
|
372
|
Chris@16
|
373 template <typename Modifiers, typename A0>
|
Chris@16
|
374 struct make_primitive<
|
Chris@16
|
375 terminal_ex<tag::long_double, fusion::vector1<A0> >, Modifiers>
|
Chris@16
|
376 : detail::make_real_direct<long double, Modifiers> {};
|
Chris@16
|
377
|
Chris@16
|
378 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
379 template <typename T, typename Policies, typename A0, typename Modifiers>
|
Chris@16
|
380 struct make_primitive<
|
Chris@16
|
381 terminal_ex<tag::stateful_tag<Policies, tag::double_, T>
|
Chris@16
|
382 , fusion::vector1<A0> >
|
Chris@16
|
383 , Modifiers>
|
Chris@16
|
384 : detail::make_real_direct<typename remove_const<T>::type
|
Chris@16
|
385 , Modifiers, Policies> {};
|
Chris@16
|
386
|
Chris@16
|
387 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
388 namespace detail
|
Chris@16
|
389 {
|
Chris@16
|
390 template <typename T, typename Modifiers>
|
Chris@16
|
391 struct basic_real_literal
|
Chris@16
|
392 {
|
Chris@16
|
393 static bool const lower =
|
Chris@16
|
394 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
|
Chris@16
|
395 static bool const upper =
|
Chris@16
|
396 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
|
Chris@16
|
397
|
Chris@16
|
398 typedef literal_real_generator<
|
Chris@16
|
399 T, real_policies<T>
|
Chris@16
|
400 , typename spirit::detail::get_encoding_with_case<
|
Chris@16
|
401 Modifiers, unused_type, lower || upper>::type
|
Chris@16
|
402 , typename detail::get_casetag<Modifiers, lower || upper>::type
|
Chris@16
|
403 , true
|
Chris@16
|
404 > result_type;
|
Chris@16
|
405
|
Chris@16
|
406 template <typename T_>
|
Chris@16
|
407 result_type operator()(T_ i, unused_type) const
|
Chris@16
|
408 {
|
Chris@16
|
409 return result_type(T(i));
|
Chris@16
|
410 }
|
Chris@16
|
411 };
|
Chris@16
|
412 }
|
Chris@16
|
413
|
Chris@16
|
414 template <typename Modifiers>
|
Chris@16
|
415 struct make_primitive<float, Modifiers>
|
Chris@16
|
416 : detail::basic_real_literal<float, Modifiers> {};
|
Chris@16
|
417
|
Chris@16
|
418 template <typename Modifiers>
|
Chris@16
|
419 struct make_primitive<double, Modifiers>
|
Chris@16
|
420 : detail::basic_real_literal<double, Modifiers> {};
|
Chris@16
|
421
|
Chris@16
|
422 template <typename Modifiers>
|
Chris@16
|
423 struct make_primitive<long double, Modifiers>
|
Chris@16
|
424 : detail::basic_real_literal<long double, Modifiers> {};
|
Chris@16
|
425
|
Chris@16
|
426 // lit(double)
|
Chris@16
|
427 template <typename Modifiers, typename A0>
|
Chris@16
|
428 struct make_primitive<
|
Chris@16
|
429 terminal_ex<tag::lit, fusion::vector1<A0> >
|
Chris@16
|
430 , Modifiers
|
Chris@16
|
431 , typename enable_if<traits::is_real<A0> >::type>
|
Chris@16
|
432 {
|
Chris@16
|
433 static bool const lower =
|
Chris@16
|
434 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
|
Chris@16
|
435 static bool const upper =
|
Chris@16
|
436 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
|
Chris@16
|
437
|
Chris@16
|
438 typedef literal_real_generator<
|
Chris@16
|
439 typename remove_const<A0>::type, real_policies<A0>
|
Chris@16
|
440 , typename spirit::detail::get_encoding_with_case<
|
Chris@16
|
441 Modifiers, unused_type, lower || upper>::type
|
Chris@16
|
442 , typename detail::get_casetag<Modifiers, lower || upper>::type
|
Chris@16
|
443 , true
|
Chris@16
|
444 > result_type;
|
Chris@16
|
445
|
Chris@16
|
446 template <typename Terminal>
|
Chris@16
|
447 result_type operator()(Terminal const& term, unused_type) const
|
Chris@16
|
448 {
|
Chris@16
|
449 return result_type(fusion::at_c<0>(term.args));
|
Chris@16
|
450 }
|
Chris@16
|
451 };
|
Chris@16
|
452 }}}
|
Chris@16
|
453
|
Chris@16
|
454 #endif // defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)
|