1 #ifndef BOOST_METAPARSE_V1_IMPL_UPDATE_C_HPP
2 #define BOOST_METAPARSE_V1_IMPL_UPDATE_C_HPP
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/metaparse/config.hpp>
10 #include <boost/metaparse/v1/fwd/string.hpp>
11 #include <boost/metaparse/v1/impl/split_at_c.hpp>
12 #include <boost/metaparse/v1/impl/concat.hpp>
14 #include <boost/preprocessor/arithmetic/dec.hpp>
15 #include <boost/preprocessor/arithmetic/inc.hpp>
16 #include <boost/preprocessor/cat.hpp>
17 #include <boost/preprocessor/punctuation/comma_if.hpp>
18 #include <boost/preprocessor/repetition/enum_params.hpp>
19 #include <boost/preprocessor/repetition/repeat.hpp>
20 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
30 #ifndef BOOST_METAPARSE_VARIADIC_STRING
31 template <class S, int N, int C>
34 #ifdef BOOST_METAPARSE_ARGN
35 # error BOOST_METAPARSE_ARGN already defined
37 #define BOOST_METAPARSE_ARGN(z, n, unused) , BOOST_PP_CAT(C, n)
39 #ifdef BOOST_METAPARSE_UPDATE
40 # error BOOST_METAPARSE_UPDATE already defined
42 #define BOOST_METAPARSE_UPDATE(z, n, unused) \
44 BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C), \
48 string<BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C)>,\
53 BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \
55 BOOST_PP_REPEAT_FROM_TO( \
57 BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_STRING_SIZE), \
58 BOOST_METAPARSE_ARGN, \
65 BOOST_METAPARSE_LIMIT_STRING_SIZE,
66 BOOST_METAPARSE_UPDATE,
70 #undef BOOST_METAPARSE_UPDATE
71 #undef BOOST_METAPARSE_ARGN
73 template <class S, int N, char C>
76 typename split_at_c<N, S>::type::first,
78 update_c<typename split_at_c<N, S>::type::second, 0, C>::type
82 template <char... Cs, char C, char NewChar>
83 struct update_c<string<C, Cs...>, 0, NewChar> :
84 string<NewChar, Cs...>