annotate DEPENDENCIES/generic/include/boost/spirit/home/karma/numeric/int.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2012 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_INT_FEB_23_2007_0840PM)
Chris@16 7 #define BOOST_SPIRIT_KARMA_INT_FEB_23_2007_0840PM
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/limits.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
Chris@16 18 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 19 #include <boost/spirit/home/support/string_traits.hpp>
Chris@16 20 #include <boost/spirit/home/support/numeric_traits.hpp>
Chris@16 21 #include <boost/spirit/home/support/info.hpp>
Chris@16 22 #include <boost/spirit/home/support/char_class.hpp>
Chris@16 23 #include <boost/spirit/home/support/container.hpp>
Chris@16 24 #include <boost/spirit/home/support/detail/get_encoding.hpp>
Chris@16 25 #include <boost/spirit/home/support/detail/is_spirit_tag.hpp>
Chris@16 26 #include <boost/spirit/home/karma/meta_compiler.hpp>
Chris@16 27 #include <boost/spirit/home/karma/delimit_out.hpp>
Chris@16 28 #include <boost/spirit/home/karma/auxiliary/lazy.hpp>
Chris@16 29 #include <boost/spirit/home/karma/detail/get_casetag.hpp>
Chris@16 30 #include <boost/spirit/home/karma/detail/extract_from.hpp>
Chris@16 31 #include <boost/spirit/home/karma/detail/enable_lit.hpp>
Chris@16 32 #include <boost/spirit/home/karma/domain.hpp>
Chris@16 33 #include <boost/spirit/home/karma/numeric/detail/numeric_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 ///////////////////////////////////////////////////////////////////////////////
Chris@16 39 namespace boost { namespace spirit
Chris@16 40 {
Chris@16 41 namespace tag
Chris@16 42 {
Chris@16 43 template <typename T, unsigned Radix, bool force_sign>
Chris@16 44 struct int_generator
Chris@16 45 {
Chris@16 46 BOOST_SPIRIT_IS_TAG()
Chris@16 47 };
Chris@16 48 }
Chris@16 49
Chris@16 50 namespace karma
Chris@16 51 {
Chris@16 52 ///////////////////////////////////////////////////////////////////////
Chris@16 53 // This one is the class that the user can instantiate directly in
Chris@16 54 // order to create a customized int generator
Chris@16 55 template <typename T = int, unsigned Radix = 10, bool force_sign = false>
Chris@16 56 struct int_generator
Chris@16 57 : spirit::terminal<tag::int_generator<T, Radix, force_sign> >
Chris@16 58 {};
Chris@16 59 }
Chris@16 60
Chris@16 61 ///////////////////////////////////////////////////////////////////////////
Chris@16 62 // Enablers
Chris@16 63 ///////////////////////////////////////////////////////////////////////////
Chris@16 64 template <>
Chris@16 65 struct use_terminal<karma::domain, tag::short_> // enables short_
Chris@16 66 : mpl::true_ {};
Chris@16 67
Chris@16 68 template <>
Chris@16 69 struct use_terminal<karma::domain, tag::int_> // enables int_
Chris@16 70 : mpl::true_ {};
Chris@16 71
Chris@16 72 template <>
Chris@16 73 struct use_terminal<karma::domain, tag::long_> // enables long_
Chris@16 74 : mpl::true_ {};
Chris@16 75
Chris@16 76 #ifdef BOOST_HAS_LONG_LONG
Chris@16 77 template <>
Chris@16 78 struct use_terminal<karma::domain, tag::long_long> // enables long_long
Chris@16 79 : mpl::true_ {};
Chris@16 80 #endif
Chris@16 81
Chris@16 82 ///////////////////////////////////////////////////////////////////////////
Chris@16 83 template <>
Chris@16 84 struct use_terminal<karma::domain, short> // enables lit(short(0))
Chris@16 85 : mpl::true_ {};
Chris@16 86
Chris@16 87 template <>
Chris@16 88 struct use_terminal<karma::domain, int> // enables lit(0)
Chris@16 89 : mpl::true_ {};
Chris@16 90
Chris@16 91 template <>
Chris@16 92 struct use_terminal<karma::domain, long> // enables lit(0L)
Chris@16 93 : mpl::true_ {};
Chris@16 94
Chris@16 95 #ifdef BOOST_HAS_LONG_LONG
Chris@16 96 template <>
Chris@16 97 struct use_terminal<karma::domain, boost::long_long_type> // enables lit(0LL)
Chris@16 98 : mpl::true_ {};
Chris@16 99 #endif
Chris@16 100
Chris@16 101 ///////////////////////////////////////////////////////////////////////////
Chris@16 102 template <typename A0>
Chris@16 103 struct use_terminal<karma::domain // enables short_(...)
Chris@16 104 , terminal_ex<tag::short_, fusion::vector1<A0> >
Chris@16 105 > : mpl::true_ {};
Chris@16 106
Chris@16 107 template <typename A0>
Chris@16 108 struct use_terminal<karma::domain // enables int_(...)
Chris@16 109 , terminal_ex<tag::int_, fusion::vector1<A0> >
Chris@16 110 > : mpl::true_ {};
Chris@16 111
Chris@16 112 template <typename A0>
Chris@16 113 struct use_terminal<karma::domain // enables long_(...)
Chris@16 114 , terminal_ex<tag::long_, fusion::vector1<A0> >
Chris@16 115 > : mpl::true_ {};
Chris@16 116
Chris@16 117 #ifdef BOOST_HAS_LONG_LONG
Chris@16 118 template <typename A0>
Chris@16 119 struct use_terminal<karma::domain // enables long_long(...)
Chris@16 120 , terminal_ex<tag::long_long, fusion::vector1<A0> >
Chris@16 121 > : mpl::true_ {};
Chris@16 122 #endif
Chris@16 123
Chris@16 124 ///////////////////////////////////////////////////////////////////////////
Chris@16 125 template <> // enables *lazy* short_(...)
Chris@16 126 struct use_lazy_terminal<karma::domain, tag::short_, 1>
Chris@16 127 : mpl::true_ {};
Chris@16 128
Chris@16 129 template <> // enables *lazy* int_(...)
Chris@16 130 struct use_lazy_terminal<karma::domain, tag::int_, 1>
Chris@16 131 : mpl::true_ {};
Chris@16 132
Chris@16 133 template <> // enables *lazy* long_(...)
Chris@16 134 struct use_lazy_terminal<karma::domain, tag::long_, 1>
Chris@16 135 : mpl::true_ {};
Chris@16 136
Chris@16 137 #ifdef BOOST_HAS_LONG_LONG
Chris@16 138 template <> // enables *lazy* long_long(...)
Chris@16 139 struct use_lazy_terminal<karma::domain, tag::long_long, 1>
Chris@16 140 : mpl::true_ {};
Chris@16 141 #endif
Chris@16 142
Chris@16 143 ///////////////////////////////////////////////////////////////////////////
Chris@16 144 // enables any custom int_generator
Chris@16 145 template <typename T, unsigned Radix, bool force_sign>
Chris@16 146 struct use_terminal<karma::domain, tag::int_generator<T, Radix, force_sign> >
Chris@16 147 : mpl::true_ {};
Chris@16 148
Chris@16 149 // enables any custom int_generator(...)
Chris@16 150 template <typename T, unsigned Radix, bool force_sign, typename A0>
Chris@16 151 struct use_terminal<karma::domain
Chris@16 152 , terminal_ex<tag::int_generator<T, Radix, force_sign>
Chris@16 153 , fusion::vector1<A0> >
Chris@16 154 > : mpl::true_ {};
Chris@16 155
Chris@16 156 // enables *lazy* custom int_generator
Chris@16 157 template <typename T, unsigned Radix, bool force_sign>
Chris@16 158 struct use_lazy_terminal<
Chris@16 159 karma::domain
Chris@16 160 , tag::int_generator<T, Radix, force_sign>
Chris@16 161 , 1 // arity
Chris@16 162 > : mpl::true_ {};
Chris@16 163
Chris@16 164 // enables lit(int)
Chris@16 165 template <typename A0>
Chris@16 166 struct use_terminal<karma::domain
Chris@16 167 , terminal_ex<tag::lit, fusion::vector1<A0> >
Chris@16 168 , typename enable_if<traits::is_int<A0> >::type>
Chris@16 169 : mpl::true_ {};
Chris@16 170 }}
Chris@16 171
Chris@16 172 ///////////////////////////////////////////////////////////////////////////////
Chris@16 173 namespace boost { namespace spirit { namespace karma
Chris@16 174 {
Chris@16 175 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 176 using spirit::short_;
Chris@16 177 using spirit::int_;
Chris@16 178 using spirit::long_;
Chris@16 179 #ifdef BOOST_HAS_LONG_LONG
Chris@16 180 using spirit::long_long;
Chris@16 181 #endif
Chris@16 182 using spirit::lit; // lit(1) is equivalent to 1
Chris@16 183 #endif
Chris@16 184
Chris@16 185 using spirit::short_type;
Chris@16 186 using spirit::int_type;
Chris@16 187 using spirit::long_type;
Chris@16 188 #ifdef BOOST_HAS_LONG_LONG
Chris@16 189 using spirit::long_long_type;
Chris@16 190 #endif
Chris@16 191
Chris@16 192 using spirit::lit_type;
Chris@16 193
Chris@16 194 ///////////////////////////////////////////////////////////////////////////
Chris@16 195 // This specialization is used for int generators not having a direct
Chris@16 196 // initializer: int_, long_ etc. These generators must be used in
Chris@16 197 // conjunction with an Attribute.
Chris@16 198 ///////////////////////////////////////////////////////////////////////////
Chris@16 199 template <
Chris@16 200 typename T, typename CharEncoding, typename Tag, unsigned Radix
Chris@16 201 , bool force_sign>
Chris@16 202 struct any_int_generator
Chris@16 203 : primitive_generator<any_int_generator<T, CharEncoding, Tag, Radix
Chris@16 204 , force_sign> >
Chris@16 205 {
Chris@16 206 private:
Chris@16 207 template <typename OutputIterator, typename Attribute>
Chris@16 208 static bool insert_int(OutputIterator& sink, Attribute const& attr)
Chris@16 209 {
Chris@16 210 return sign_inserter::call(sink, traits::test_zero(attr)
Chris@16 211 , traits::test_negative(attr), force_sign) &&
Chris@16 212 int_inserter<Radix, CharEncoding, Tag>::call(sink
Chris@16 213 , traits::get_absolute_value(attr));
Chris@16 214 }
Chris@16 215
Chris@16 216 public:
Chris@16 217 template <typename Context, typename Unused>
Chris@16 218 struct attribute
Chris@16 219 {
Chris@16 220 typedef T type;
Chris@16 221 };
Chris@16 222
Chris@16 223 // check template Attribute 'Radix' for validity
Chris@16 224 BOOST_SPIRIT_ASSERT_MSG(
Chris@16 225 Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
Chris@16 226 not_supported_radix, ());
Chris@16 227
Chris@16 228 BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
Chris@16 229 signed_unsigned_mismatch, ());
Chris@16 230
Chris@16 231 // int has a Attribute attached
Chris@16 232 template <typename OutputIterator, typename Context, typename Delimiter
Chris@16 233 , typename Attribute>
Chris@16 234 static bool
Chris@16 235 generate(OutputIterator& sink, Context& context, Delimiter const& d
Chris@16 236 , Attribute const& attr)
Chris@16 237 {
Chris@16 238 if (!traits::has_optional_value(attr))
Chris@16 239 return false; // fail if it's an uninitialized optional
Chris@16 240
Chris@16 241 return insert_int(sink, traits::extract_from<T>(attr, context)) &&
Chris@16 242 delimit_out(sink, d); // always do post-delimiting
Chris@16 243 }
Chris@16 244
Chris@16 245 // this int has no Attribute attached, it needs to have been
Chris@16 246 // initialized from a direct literal
Chris@16 247 template <typename OutputIterator, typename Context, typename Delimiter>
Chris@16 248 static bool
Chris@16 249 generate(OutputIterator&, Context&, Delimiter const&, unused_type)
Chris@16 250 {
Chris@16 251 // It is not possible (doesn't make sense) to use numeric generators
Chris@16 252 // without providing any attribute, as the generator doesn't 'know'
Chris@16 253 // what to output. The following assertion fires if this situation
Chris@16 254 // is detected in your code.
Chris@16 255 BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, int_not_usable_without_attribute, ());
Chris@16 256 return false;
Chris@16 257 }
Chris@16 258
Chris@16 259 template <typename Context>
Chris@16 260 static info what(Context const& /*context*/)
Chris@16 261 {
Chris@16 262 return info("integer");
Chris@16 263 }
Chris@16 264 };
Chris@16 265
Chris@16 266 ///////////////////////////////////////////////////////////////////////////
Chris@16 267 // This specialization is used for int generators having a direct
Chris@16 268 // initializer: int_(10), long_(20) etc.
Chris@16 269 ///////////////////////////////////////////////////////////////////////////
Chris@16 270 template <
Chris@16 271 typename T, typename CharEncoding, typename Tag, unsigned Radix
Chris@16 272 , bool force_sign, bool no_attribute>
Chris@16 273 struct literal_int_generator
Chris@16 274 : primitive_generator<literal_int_generator<T, CharEncoding, Tag, Radix
Chris@16 275 , force_sign, no_attribute> >
Chris@16 276 {
Chris@16 277 private:
Chris@16 278 template <typename OutputIterator, typename Attribute>
Chris@16 279 static bool insert_int(OutputIterator& sink, Attribute const& attr)
Chris@16 280 {
Chris@16 281 return sign_inserter::call(sink, traits::test_zero(attr)
Chris@16 282 , traits::test_negative(attr), force_sign) &&
Chris@16 283 int_inserter<Radix, CharEncoding, Tag>::call(sink
Chris@16 284 , traits::get_absolute_value(attr));
Chris@16 285 }
Chris@16 286
Chris@16 287 public:
Chris@16 288 template <typename Context, typename Unused = unused_type>
Chris@16 289 struct attribute
Chris@16 290 : mpl::if_c<no_attribute, unused_type, T>
Chris@16 291 {};
Chris@16 292
Chris@16 293 literal_int_generator(typename add_const<T>::type n)
Chris@16 294 : n_(n) {}
Chris@16 295
Chris@16 296 // check template Attribute 'Radix' for validity
Chris@16 297 BOOST_SPIRIT_ASSERT_MSG(
Chris@16 298 Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
Chris@16 299 not_supported_radix, ());
Chris@16 300
Chris@16 301 BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
Chris@16 302 signed_unsigned_mismatch, ());
Chris@16 303
Chris@16 304 // A int_(1) which additionally has an associated attribute emits
Chris@16 305 // its immediate literal only if it matches the attribute, otherwise
Chris@16 306 // it fails.
Chris@16 307 template <typename OutputIterator, typename Context, typename Delimiter
Chris@16 308 , typename Attribute>
Chris@16 309 bool generate(OutputIterator& sink, Context& context
Chris@16 310 , Delimiter const& d, Attribute const& attr) const
Chris@16 311 {
Chris@16 312 typedef typename attribute<Context>::type attribute_type;
Chris@16 313 if (!traits::has_optional_value(attr) ||
Chris@16 314 n_ != traits::extract_from<attribute_type>(attr, context))
Chris@16 315 {
Chris@16 316 return false;
Chris@16 317 }
Chris@16 318 return insert_int(sink, n_) && delimit_out(sink, d);
Chris@16 319 }
Chris@16 320
Chris@16 321 // A int_(1) without any associated attribute just emits its
Chris@16 322 // immediate literal
Chris@16 323 template <typename OutputIterator, typename Context, typename Delimiter>
Chris@16 324 bool generate(OutputIterator& sink, Context&, Delimiter const& d
Chris@16 325 , unused_type) const
Chris@16 326 {
Chris@16 327 return insert_int(sink, n_) && delimit_out(sink, d);
Chris@16 328 }
Chris@16 329
Chris@16 330 template <typename Context>
Chris@16 331 static info what(Context const& /*context*/)
Chris@16 332 {
Chris@16 333 return info("integer");
Chris@16 334 }
Chris@16 335
Chris@16 336 T n_;
Chris@16 337 };
Chris@16 338
Chris@16 339 ///////////////////////////////////////////////////////////////////////////
Chris@16 340 // Generator generators: make_xxx function (objects)
Chris@16 341 ///////////////////////////////////////////////////////////////////////////
Chris@16 342 namespace detail
Chris@16 343 {
Chris@16 344 template <typename T, typename Modifiers, unsigned Radix = 10
Chris@16 345 , bool force_sign = false>
Chris@16 346 struct make_int
Chris@16 347 {
Chris@16 348 static bool const lower =
Chris@16 349 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
Chris@16 350 static bool const upper =
Chris@16 351 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
Chris@16 352
Chris@16 353 typedef any_int_generator<
Chris@16 354 T
Chris@16 355 , typename spirit::detail::get_encoding_with_case<
Chris@16 356 Modifiers, unused_type, lower || upper>::type
Chris@16 357 , typename detail::get_casetag<Modifiers, lower || upper>::type
Chris@16 358 , Radix
Chris@16 359 , force_sign
Chris@16 360 > result_type;
Chris@16 361
Chris@16 362 result_type operator()(unused_type, unused_type) const
Chris@16 363 {
Chris@16 364 return result_type();
Chris@16 365 }
Chris@16 366 };
Chris@16 367 }
Chris@16 368
Chris@16 369 ///////////////////////////////////////////////////////////////////////////
Chris@16 370 template <typename Modifiers>
Chris@16 371 struct make_primitive<tag::short_, Modifiers>
Chris@16 372 : detail::make_int<short, Modifiers> {};
Chris@16 373
Chris@16 374 template <typename Modifiers>
Chris@16 375 struct make_primitive<tag::int_, Modifiers>
Chris@16 376 : detail::make_int<int, Modifiers> {};
Chris@16 377
Chris@16 378 template <typename Modifiers>
Chris@16 379 struct make_primitive<tag::long_, Modifiers>
Chris@16 380 : detail::make_int<long, Modifiers> {};
Chris@16 381
Chris@16 382 #ifdef BOOST_HAS_LONG_LONG
Chris@16 383 template <typename Modifiers>
Chris@16 384 struct make_primitive<tag::long_long, Modifiers>
Chris@16 385 : detail::make_int<boost::long_long_type, Modifiers> {};
Chris@16 386 #endif
Chris@16 387
Chris@16 388 template <typename T, unsigned Radix, bool force_sign, typename Modifiers>
Chris@16 389 struct make_primitive<tag::int_generator<T, Radix, force_sign>, Modifiers>
Chris@16 390 : detail::make_int<typename remove_const<T>::type
Chris@16 391 , Modifiers, Radix, force_sign> {};
Chris@16 392
Chris@16 393 ///////////////////////////////////////////////////////////////////////////
Chris@16 394 namespace detail
Chris@16 395 {
Chris@16 396 template <typename T, typename Modifiers, unsigned Radix = 10
Chris@16 397 , bool force_sign = false>
Chris@16 398 struct make_int_direct
Chris@16 399 {
Chris@16 400 static bool const lower =
Chris@16 401 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
Chris@16 402 static bool const upper =
Chris@16 403 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
Chris@16 404
Chris@16 405 typedef literal_int_generator<
Chris@16 406 T
Chris@16 407 , typename spirit::detail::get_encoding_with_case<
Chris@16 408 Modifiers, unused_type, lower || upper>::type
Chris@16 409 , typename detail::get_casetag<Modifiers, lower || upper>::type
Chris@16 410 , Radix, force_sign, false
Chris@16 411 > result_type;
Chris@16 412
Chris@16 413 template <typename Terminal>
Chris@16 414 result_type operator()(Terminal const& term, unused_type) const
Chris@16 415 {
Chris@16 416 return result_type(fusion::at_c<0>(term.args));
Chris@16 417 }
Chris@16 418 };
Chris@16 419 }
Chris@16 420
Chris@16 421 ///////////////////////////////////////////////////////////////////////////
Chris@16 422 template <typename Modifiers, typename A0>
Chris@16 423 struct make_primitive<
Chris@16 424 terminal_ex<tag::short_, fusion::vector1<A0> >, Modifiers>
Chris@16 425 : detail::make_int_direct<short, Modifiers> {};
Chris@16 426
Chris@16 427 template <typename Modifiers, typename A0>
Chris@16 428 struct make_primitive<
Chris@16 429 terminal_ex<tag::int_, fusion::vector1<A0> >, Modifiers>
Chris@16 430 : detail::make_int_direct<int, Modifiers> {};
Chris@16 431
Chris@16 432 template <typename Modifiers, typename A0>
Chris@16 433 struct make_primitive<
Chris@16 434 terminal_ex<tag::long_, fusion::vector1<A0> >, Modifiers>
Chris@16 435 : detail::make_int_direct<long, Modifiers> {};
Chris@16 436
Chris@16 437 #ifdef BOOST_HAS_LONG_LONG
Chris@16 438 template <typename Modifiers, typename A0>
Chris@16 439 struct make_primitive<
Chris@16 440 terminal_ex<tag::long_long, fusion::vector1<A0> >, Modifiers>
Chris@16 441 : detail::make_int_direct<boost::long_long_type, Modifiers> {};
Chris@16 442 #endif
Chris@16 443
Chris@16 444 template <typename T, unsigned Radix, bool force_sign, typename A0
Chris@16 445 , typename Modifiers>
Chris@16 446 struct make_primitive<
Chris@16 447 terminal_ex<tag::int_generator<T, Radix, force_sign>
Chris@16 448 , fusion::vector1<A0> >, Modifiers>
Chris@16 449 : detail::make_int_direct<typename remove_const<T>::type
Chris@16 450 , Modifiers, Radix, force_sign> {};
Chris@16 451
Chris@16 452 ///////////////////////////////////////////////////////////////////////////
Chris@16 453 namespace detail
Chris@16 454 {
Chris@16 455 template <typename T, typename Modifiers>
Chris@16 456 struct basic_int_literal
Chris@16 457 {
Chris@16 458 static bool const lower =
Chris@16 459 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
Chris@16 460 static bool const upper =
Chris@16 461 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
Chris@16 462
Chris@16 463 typedef literal_int_generator<
Chris@16 464 T
Chris@16 465 , typename spirit::detail::get_encoding_with_case<
Chris@16 466 Modifiers, unused_type, lower || upper>::type
Chris@16 467 , typename detail::get_casetag<Modifiers, lower || upper>::type
Chris@16 468 , 10, false, true
Chris@16 469 > result_type;
Chris@16 470
Chris@16 471 template <typename T_>
Chris@16 472 result_type operator()(T_ i, unused_type) const
Chris@16 473 {
Chris@16 474 return result_type(i);
Chris@16 475 }
Chris@16 476 };
Chris@16 477 }
Chris@16 478
Chris@16 479 template <typename Modifiers>
Chris@16 480 struct make_primitive<short, Modifiers>
Chris@16 481 : detail::basic_int_literal<short, Modifiers> {};
Chris@16 482
Chris@16 483 template <typename Modifiers>
Chris@16 484 struct make_primitive<int, Modifiers>
Chris@16 485 : detail::basic_int_literal<int, Modifiers> {};
Chris@16 486
Chris@16 487 template <typename Modifiers>
Chris@16 488 struct make_primitive<long, Modifiers>
Chris@16 489 : detail::basic_int_literal<long, Modifiers> {};
Chris@16 490
Chris@16 491 #ifdef BOOST_HAS_LONG_LONG
Chris@16 492 template <typename Modifiers>
Chris@16 493 struct make_primitive<boost::long_long_type, Modifiers>
Chris@16 494 : detail::basic_int_literal<boost::long_long_type, Modifiers> {};
Chris@16 495 #endif
Chris@16 496
Chris@16 497 // lit(int)
Chris@16 498 template <typename Modifiers, typename A0>
Chris@16 499 struct make_primitive<
Chris@16 500 terminal_ex<tag::lit, fusion::vector1<A0> >
Chris@16 501 , Modifiers
Chris@16 502 , typename enable_if<traits::is_int<A0> >::type>
Chris@16 503 {
Chris@16 504 static bool const lower =
Chris@16 505 has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
Chris@16 506 static bool const upper =
Chris@16 507 has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
Chris@16 508
Chris@16 509 typedef literal_int_generator<
Chris@16 510 typename remove_const<A0>::type
Chris@16 511 , typename spirit::detail::get_encoding_with_case<
Chris@16 512 Modifiers, unused_type, lower || upper>::type
Chris@16 513 , typename detail::get_casetag<Modifiers, lower || upper>::type
Chris@16 514 , 10, false, true
Chris@16 515 > result_type;
Chris@16 516
Chris@16 517 template <typename Terminal>
Chris@16 518 result_type operator()(Terminal const& term, unused_type) const
Chris@16 519 {
Chris@16 520 return result_type(fusion::at_c<0>(term.args));
Chris@16 521 }
Chris@16 522 };
Chris@16 523 }}}
Chris@16 524
Chris@16 525 #endif