size.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef BOOST_METAPARSE_V1_CPP98_IMPL_SIZE_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_IMPL_SIZE_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/cpp98/fwd/string.hpp>
  8. #include <boost/mpl/int.hpp>
  9. #include <boost/preprocessor/arithmetic/sub.hpp>
  10. #include <boost/preprocessor/punctuation/comma_if.hpp>
  11. #include <boost/preprocessor/repetition/enum.hpp>
  12. #include <boost/preprocessor/repetition/enum_params.hpp>
  13. #include <boost/preprocessor/repetition/repeat.hpp>
  14. #include <boost/preprocessor/tuple/eat.hpp>
  15. namespace boost
  16. {
  17. namespace metaparse
  18. {
  19. namespace v1
  20. {
  21. namespace impl
  22. {
  23. template <class S>
  24. struct size;
  25. #ifdef BOOST_METAPARSE_STRING_CASE
  26. # error BOOST_METAPARSE_STRING_CASE
  27. #endif
  28. #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \
  29. template <BOOST_PP_ENUM_PARAMS(n, int C)> \
  30. struct \
  31. size< \
  32. string< \
  33. BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \
  34. BOOST_PP_ENUM( \
  35. BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \
  36. BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \
  37. ~ \
  38. ) \
  39. > \
  40. > : \
  41. boost::mpl::int_<n> \
  42. {};
  43. BOOST_PP_REPEAT(
  44. BOOST_METAPARSE_LIMIT_STRING_SIZE,
  45. BOOST_METAPARSE_STRING_CASE,
  46. ~
  47. )
  48. #undef BOOST_METAPARSE_STRING_CASE
  49. }
  50. }
  51. }
  52. }
  53. #endif