update_c.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef BOOST_METAPARSE_V1_CPP98_IMPL_UPDATE_C_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_IMPL_UPDATE_C_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/preprocessor/arithmetic/dec.hpp>
  9. #include <boost/preprocessor/arithmetic/inc.hpp>
  10. #include <boost/preprocessor/cat.hpp>
  11. #include <boost/preprocessor/punctuation/comma_if.hpp>
  12. #include <boost/preprocessor/repetition/enum_params.hpp>
  13. #include <boost/preprocessor/repetition/repeat.hpp>
  14. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  15. namespace boost
  16. {
  17. namespace metaparse
  18. {
  19. namespace v1
  20. {
  21. namespace impl
  22. {
  23. template <class S, int N, int C>
  24. struct update_c;
  25. #ifdef BOOST_METAPARSE_ARGN
  26. # error BOOST_METAPARSE_ARGN already defined
  27. #endif
  28. #define BOOST_METAPARSE_ARGN(z, n, unused) , BOOST_PP_CAT(C, n)
  29. #ifdef BOOST_METAPARSE_UPDATE
  30. # error BOOST_METAPARSE_UPDATE already defined
  31. #endif
  32. #define BOOST_METAPARSE_UPDATE(z, n, unused) \
  33. template < \
  34. BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C), \
  35. int Ch \
  36. > \
  37. struct update_c< \
  38. string<BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C)>,\
  39. n, \
  40. Ch \
  41. > : \
  42. string< \
  43. BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \
  44. Ch \
  45. BOOST_PP_REPEAT_FROM_TO( \
  46. BOOST_PP_INC(n), \
  47. BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_STRING_SIZE), \
  48. BOOST_METAPARSE_ARGN, \
  49. ~ \
  50. ) \
  51. > \
  52. {};
  53. BOOST_PP_REPEAT(
  54. BOOST_METAPARSE_LIMIT_STRING_SIZE,
  55. BOOST_METAPARSE_UPDATE,
  56. ~
  57. )
  58. #undef BOOST_METAPARSE_UPDATE
  59. #undef BOOST_METAPARSE_ARGN
  60. }
  61. }
  62. }
  63. }
  64. #endif