diff options
Diffstat (limited to 'boost/metaparse')
30 files changed, 968 insertions, 766 deletions
diff --git a/boost/metaparse/config.hpp b/boost/metaparse/config.hpp index a9a42dbb60..2e8e6a2931 100644 --- a/boost/metaparse/config.hpp +++ b/boost/metaparse/config.hpp @@ -24,17 +24,40 @@ #endif /* - * Metaparse config + * C++ standard to use */ -#if \ - !defined BOOST_NO_CXX11_VARIADIC_TEMPLATES \ - && !defined BOOST_NO_VARIADIC_TEMPLATES \ - && !defined BOOST_METAPARSE_VARIADIC_STRING +// Allow overriding this +#ifndef BOOST_METAPARSE_STD -# define BOOST_METAPARSE_VARIADIC_STRING +// special-case MSCV >= 1900 as its constexpr support is good enough for +// Metaparse +# if \ + !defined BOOST_NO_CXX11_VARIADIC_TEMPLATES \ + && !defined BOOST_NO_VARIADIC_TEMPLATES \ + && ( \ + (!defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR) \ + || (defined _MSC_VER && _MSC_VER >= 1900) \ + ) \ + && (!defined BOOST_GCC || BOOST_GCC >= 40700) + +# define BOOST_METAPARSE_STD 2011 + +# else + +# define BOOST_METAPARSE_STD 1998 + +# endif #endif +/* + * Metaparse config + */ + +#if BOOST_METAPARSE_STD >= 2011 +# define BOOST_METAPARSE_VARIADIC_STRING +#endif + #endif diff --git a/boost/metaparse/v1/cpp11/fwd/string.hpp b/boost/metaparse/v1/cpp11/fwd/string.hpp new file mode 100644 index 0000000000..562ade400d --- /dev/null +++ b/boost/metaparse/v1/cpp11/fwd/string.hpp @@ -0,0 +1,22 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_FWD_STRING_HPP +#define BOOST_METAPARSE_V1_CPP11_FWD_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template <char... Cs> + struct string; + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp11/impl/at_c.hpp b/boost/metaparse/v1/cpp11/impl/at_c.hpp new file mode 100644 index 0000000000..17332af1f6 --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/at_c.hpp @@ -0,0 +1,35 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_AT_C_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_AT_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +#include <boost/mpl/char.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S, int N> + struct at_c; + + template <char C, char... Cs, int N> + struct at_c<string<C, Cs...>, N> : at_c<string<Cs...>, N - 1> {}; + + template <char C, char... Cs> + struct at_c<string<C, Cs...>, 0> : boost::mpl::char_<C> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp11/impl/concat.hpp b/boost/metaparse/v1/cpp11/impl/concat.hpp new file mode 100644 index 0000000000..438a7766eb --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/concat.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_CONCAT_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_CONCAT_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class A, class B> + struct concat; + + template <char... As, char... Bs> + struct concat<string<As...>, string<Bs...>> : string<As..., Bs...> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp11/impl/empty_string.hpp b/boost/metaparse/v1/cpp11/impl/empty_string.hpp new file mode 100644 index 0000000000..93b87e4184 --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/empty_string.hpp @@ -0,0 +1,33 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_EMPTY_STRING_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_EMPTY_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class Ignore = int> + struct empty_string + { + typedef empty_string type; + + static constexpr char value[1] = {0}; + }; + + template <class Ignore> + constexpr char empty_string<Ignore>::value[1]; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/impl/pop_back.hpp b/boost/metaparse/v1/cpp11/impl/pop_back.hpp index 7c3d9b30b2..224ee00b95 100644 --- a/boost/metaparse/v1/impl/pop_back.hpp +++ b/boost/metaparse/v1/cpp11/impl/pop_back.hpp @@ -1,16 +1,14 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_POP_BACK_HPP -#define BOOST_METAPARSE_V1_IMPL_POP_BACK_HPP +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_POP_BACK_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_POP_BACK_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/metaparse/v1/impl/push_front_c.hpp> -#include <boost/metaparse/v1/impl/size.hpp> -#include <boost/metaparse/v1/impl/update_c.hpp> +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> +#include <boost/metaparse/v1/cpp11/impl/push_front_c.hpp> +#include <boost/metaparse/v1/cpp11/impl/size.hpp> #include <boost/mpl/clear.hpp> @@ -25,7 +23,6 @@ namespace boost template <class S> struct pop_back; -#ifdef BOOST_METAPARSE_VARIADIC_STRING template <char C> struct pop_back<string<C>> : boost::mpl::clear<string<C>> {}; @@ -33,16 +30,6 @@ namespace boost struct pop_back<string<C, Cs...>> : push_front_c<typename pop_back<string<Cs...>>::type, C> {}; -#else - template <class S> - struct pop_back : - update_c< - typename S::type, - size<typename S::type>::type::value - 1, - BOOST_NO_CHAR - > - {}; -#endif } } } diff --git a/boost/metaparse/v1/cpp11/impl/pop_front.hpp b/boost/metaparse/v1/cpp11/impl/pop_front.hpp new file mode 100644 index 0000000000..1d0dd74534 --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/pop_front.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_POP_FRONT_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_POP_FRONT_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S> + struct pop_front; + + template <char C, char... Cs> + struct pop_front<string<C, Cs...>> : string<Cs...> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp11/impl/push_back_c.hpp b/boost/metaparse/v1/cpp11/impl/push_back_c.hpp new file mode 100644 index 0000000000..c1e6d86bc7 --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/push_back_c.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_PUSH_BACK_C_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_PUSH_BACK_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S, char C> + struct push_back_c; + + template <char... Cs, char C> + struct push_back_c<string<Cs...>, C> : string<Cs..., C> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp11/impl/push_front_c.hpp b/boost/metaparse/v1/cpp11/impl/push_front_c.hpp new file mode 100644 index 0000000000..d450cffe70 --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/push_front_c.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_PUSH_FRONT_C_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_PUSH_FRONT_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S, char C> + struct push_front_c; + + template <char... Cs, char C> + struct push_front_c<string<Cs...>, C> : string<C, Cs...> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/impl/remove_trailing_no_chars.hpp b/boost/metaparse/v1/cpp11/impl/remove_trailing_no_chars.hpp index 7d561d2709..cdea6e4b7f 100644 --- a/boost/metaparse/v1/impl/remove_trailing_no_chars.hpp +++ b/boost/metaparse/v1/cpp11/impl/remove_trailing_no_chars.hpp @@ -1,14 +1,14 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_REMOVE_TRAILING_NO_CHARS_HPP -#define BOOST_METAPARSE_V1_IMPL_REMOVE_TRAILING_NO_CHARS_HPP +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_REMOVE_TRAILING_NO_CHARS_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_REMOVE_TRAILING_NO_CHARS_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/string.hpp> -#include <boost/metaparse/v1/impl/push_front_c.hpp> +#include <boost/metaparse/v1/cpp11/string.hpp> +#include <boost/metaparse/v1/impl/no_char.hpp> +#include <boost/metaparse/v1/cpp11/impl/push_front_c.hpp> namespace boost { @@ -21,7 +21,6 @@ namespace boost template <class S> struct remove_trailing_no_chars : S {}; -#ifdef BOOST_METAPARSE_VARIADIC_STRING // this code assumes that BOOST_NO_CHARs are at the end of the string template <char... Cs> struct remove_trailing_no_chars<string<BOOST_NO_CHAR, Cs...>> : @@ -47,7 +46,6 @@ namespace boost template <> struct remove_trailing_no_chars<string<>> : string<> {}; #endif -#endif } } } diff --git a/boost/metaparse/v1/cpp11/impl/size.hpp b/boost/metaparse/v1/cpp11/impl/size.hpp new file mode 100644 index 0000000000..a1ffa1b2db --- /dev/null +++ b/boost/metaparse/v1/cpp11/impl/size.hpp @@ -0,0 +1,34 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_SIZE_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_SIZE_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> + +#include <boost/mpl/int.hpp> + +#include <type_traits> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S> + struct size; + + template <char... Cs> + struct size<string<Cs...>> : boost::mpl::int_<sizeof...(Cs)> {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/impl/string.hpp b/boost/metaparse/v1/cpp11/impl/string.hpp index d3843cfb34..0d31a55a4d 100644 --- a/boost/metaparse/v1/impl/string.hpp +++ b/boost/metaparse/v1/cpp11/impl/string.hpp @@ -1,11 +1,11 @@ -#ifndef BOOST_METAPARSE_V1_IMPL__HPP -#define BOOST_METAPARSE_V1_IMPL__HPP +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_STRING_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_STRING_HPP // This is an automatically generated header file. // Generated with the tools/string_headers.py utility of // Boost.Metaparse -#include <boost/metaparse/v1/impl/concat.hpp> +#include <boost/metaparse/v1/cpp11/impl/concat.hpp> #include <boost/preprocessor/cat.hpp> namespace boost diff --git a/boost/metaparse/v1/impl/string_at.hpp b/boost/metaparse/v1/cpp11/impl/string_at.hpp index a465d302bf..6540d56f65 100644 --- a/boost/metaparse/v1/impl/string_at.hpp +++ b/boost/metaparse/v1/cpp11/impl/string_at.hpp @@ -1,15 +1,15 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_STRING_AT_HPP -#define BOOST_METAPARSE_V1_IMPL_STRING_AT_HPP +#ifndef BOOST_METAPARSE_V1_CPP11_IMPL_STRING_AT_HPP +#define BOOST_METAPARSE_V1_CPP11_IMPL_STRING_AT_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2016. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/static_assert.hpp> #include <boost/metaparse/v1/impl/no_char.hpp> +#include <boost/metaparse/limit_string_size.hpp> + namespace boost { namespace metaparse @@ -19,11 +19,11 @@ namespace boost namespace impl { template <int MaxLen, int Len, class T> - BOOST_CONSTEXPR int string_at(const T (&s)[Len], int n) + constexpr int string_at(const T (&s)[Len], int n) { // "MaxLen + 1" adds the \0 character of the string literal to the // limit - BOOST_STATIC_ASSERT((Len <= MaxLen + 1)); + static_assert(Len <= MaxLen + 1, "String literal is too long."); return n >= Len - 1 ? BOOST_NO_CHAR : s[n]; } } diff --git a/boost/metaparse/v1/cpp11/string.hpp b/boost/metaparse/v1/cpp11/string.hpp new file mode 100644 index 0000000000..e109b41d98 --- /dev/null +++ b/boost/metaparse/v1/cpp11/string.hpp @@ -0,0 +1,213 @@ +#ifndef BOOST_METAPARSE_V1_CPP11_STRING_HPP +#define BOOST_METAPARSE_V1_CPP11_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp11/fwd/string.hpp> +#include <boost/metaparse/v1/string_tag.hpp> +#include <boost/metaparse/v1/impl/string_iterator.hpp> +#include <boost/metaparse/v1/cpp11/impl/empty_string.hpp> +#include <boost/metaparse/v1/cpp11/impl/size.hpp> +#include <boost/metaparse/v1/cpp11/impl/pop_front.hpp> +#include <boost/metaparse/v1/cpp11/impl/push_front_c.hpp> +#include <boost/metaparse/v1/cpp11/impl/push_back_c.hpp> +#include <boost/metaparse/v1/cpp11/impl/pop_back.hpp> +#include <boost/metaparse/v1/cpp11/impl/string_at.hpp> + +#include <type_traits> + +/* + * The string type + */ + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template <char... Cs> + struct string + { + typedef string type; + typedef string_tag tag; + }; + } + } +} + +/* + * Boost.MPL overloads + */ + +namespace boost +{ + namespace mpl + { + // push_back + template <class S> + struct push_back_impl; + + template <> + struct push_back_impl<boost::metaparse::v1::string_tag> + { + typedef push_back_impl type; + + template <class S, class C> + struct apply : + boost::metaparse::v1::impl::push_back_c< + typename S::type, + C::type::value + > + {}; + }; + + // pop_back + template <class S> + struct pop_back_impl; + + template <> + struct pop_back_impl<boost::metaparse::v1::string_tag> + { + typedef pop_back_impl type; + + template <class S> + struct apply : boost::metaparse::v1::impl::pop_back<S> {}; + }; + + // push_front + template <class S> + struct push_front_impl; + + template <> + struct push_front_impl<boost::metaparse::v1::string_tag> + { + typedef push_front_impl type; + + template <class S, class C> + struct apply : + boost::metaparse::v1::impl::push_front_c< + typename S::type, + C::type::value + > + {}; + }; + + // pop_front + template <class S> + struct pop_front_impl; + + template <> + struct pop_front_impl<boost::metaparse::v1::string_tag> + { + typedef pop_front_impl type; + + template <class S> + struct apply : boost::metaparse::v1::impl::pop_front<S> {}; + }; + + // clear + template <class S> + struct clear_impl; + + template <> + struct clear_impl<boost::metaparse::v1::string_tag> + { + typedef clear_impl type; + + template <class S> + struct apply : boost::metaparse::v1::string<> {}; + }; + + // begin + template <class S> + struct begin_impl; + + template <> + struct begin_impl<boost::metaparse::v1::string_tag> + { + typedef begin_impl type; + + template <class S> + struct apply : + boost::metaparse::v1::impl::string_iterator<typename S::type, 0> + {}; + }; + + // end + template <class S> + struct end_impl; + + template <> + struct end_impl<boost::metaparse::v1::string_tag> + { + typedef end_impl type; + + template <class S> + struct apply : + boost::metaparse::v1::impl::string_iterator< + typename S::type, + boost::metaparse::v1::impl::size<typename S::type>::type::value + > + {}; + }; + + // equal_to + template <class A, class B> + struct equal_to_impl; + + template <> + struct equal_to_impl< + boost::metaparse::v1::string_tag, + boost::metaparse::v1::string_tag + > + { + typedef equal_to_impl type; + + template <class A, class B> + struct apply : std::is_same<typename A::type, typename B::type> {}; + }; + + template <class T> + struct equal_to_impl<boost::metaparse::v1::string_tag, T> + { + typedef equal_to_impl type; + + template <class, class> + struct apply : false_ {}; + }; + + template <class T> + struct equal_to_impl<T, boost::metaparse::v1::string_tag> : + equal_to_impl<boost::metaparse::v1::string_tag, T> + {}; + + // c_str + template <class S> + struct c_str; + + template <char... Cs> + struct c_str<boost::metaparse::v1::string<Cs...>> + { + typedef c_str type; + static constexpr char value[sizeof...(Cs) + 1] = {Cs..., 0}; + }; + + template <> + struct c_str<boost::metaparse::v1::string<>> : + boost::metaparse::v1::impl::empty_string<> + {}; + + template <char... Cs> + constexpr char c_str<boost::metaparse::v1::string<Cs...>>::value[]; + } +} + +#include <boost/metaparse/v1/cpp11/impl/remove_trailing_no_chars.hpp> +#include <boost/metaparse/v1/cpp11/impl/string.hpp> + +#endif + diff --git a/boost/metaparse/v1/cpp98/fwd/string.hpp b/boost/metaparse/v1/cpp98/fwd/string.hpp new file mode 100644 index 0000000000..69d80adca5 --- /dev/null +++ b/boost/metaparse/v1/cpp98/fwd/string.hpp @@ -0,0 +1,33 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_FWD_STRING_HPP +#define BOOST_METAPARSE_V1_CPP98_FWD_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/limit_string_size.hpp> +#include <boost/metaparse/v1/impl/no_char.hpp> + +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_METAPARSE_LIMIT_STRING_SIZE, + int C, + BOOST_NO_CHAR + ) + > + struct string; + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/at_c.hpp b/boost/metaparse/v1/cpp98/impl/at_c.hpp new file mode 100644 index 0000000000..469b3149e9 --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/at_c.hpp @@ -0,0 +1,58 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_AT_C_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_AT_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/config.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> + +#include <boost/mpl/char.hpp> + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S, int N> + struct at_c; + + #ifdef BOOST_METAPARSE_STRING_CASE + # error BOOST_METAPARSE_STRING_CASE is already defined + #endif + #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ + template < \ + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C) \ + > \ + struct \ + at_c< \ + string< \ + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) \ + >, \ + n \ + > : \ + boost::mpl::char_<BOOST_PP_CAT(C, n)> \ + {}; + + BOOST_PP_REPEAT( + BOOST_METAPARSE_LIMIT_STRING_SIZE, + BOOST_METAPARSE_STRING_CASE, + ~ + ) + + #undef BOOST_METAPARSE_STRING_CASE + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/empty_string.hpp b/boost/metaparse/v1/cpp98/impl/empty_string.hpp new file mode 100644 index 0000000000..362fbd3cc5 --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/empty_string.hpp @@ -0,0 +1,33 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_EMPTY_STRING_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_EMPTY_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class Ignore = int> + struct empty_string + { + typedef empty_string type; + + static const char value[1]; + }; + + template <class Ignore> + const char empty_string<Ignore>::value[1] = {0}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/pop_back.hpp b/boost/metaparse/v1/cpp98/impl/pop_back.hpp new file mode 100644 index 0000000000..e5273740b0 --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/pop_back.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_POP_BACK_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_POP_BACK_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> +#include <boost/metaparse/v1/cpp98/impl/push_front_c.hpp> +#include <boost/metaparse/v1/cpp98/impl/size.hpp> +#include <boost/metaparse/v1/cpp98/impl/update_c.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <class S> + struct pop_back; + + template <class S> + struct pop_back : + update_c< + typename S::type, + size<typename S::type>::type::value - 1, + BOOST_NO_CHAR + > + {}; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/impl/pop_front.hpp b/boost/metaparse/v1/cpp98/impl/pop_front.hpp index ac02d35aa1..6302f0aced 100644 --- a/boost/metaparse/v1/impl/pop_front.hpp +++ b/boost/metaparse/v1/cpp98/impl/pop_front.hpp @@ -1,13 +1,12 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_POP_FRONT_HPP -#define BOOST_METAPARSE_V1_IMPL_POP_FRONT_HPP +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_POP_FRONT_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_POP_FRONT_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> #include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/repeat_from_to.hpp> @@ -23,10 +22,6 @@ namespace boost template <class S> struct pop_front; -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char C, char... Cs> - struct pop_front<string<C, Cs...>> : string<Cs...> {}; -#else #ifdef BOOST_METAPARSE_POP_FRONT # error BOOST_METAPARSE_POP_FRONT already defined #endif @@ -52,7 +47,6 @@ namespace boost {}; #undef BOOST_METAPARSE_POP_FRONT -#endif } } } diff --git a/boost/metaparse/v1/impl/push_back_c.hpp b/boost/metaparse/v1/cpp98/impl/push_back_c.hpp index 453043d97c..69f9eef02c 100644 --- a/boost/metaparse/v1/impl/push_back_c.hpp +++ b/boost/metaparse/v1/cpp98/impl/push_back_c.hpp @@ -1,15 +1,14 @@ -#ifndef BOOST_METAPARSE_V1_PUSH_BACK_C_HPP -#define BOOST_METAPARSE_V1_PUSH_BACK_C_HPP +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_PUSH_BACK_C_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_PUSH_BACK_C_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/metaparse/v1/impl/update_c.hpp> -#include <boost/metaparse/v1/impl/size.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> +#include <boost/metaparse/v1/cpp98/impl/update_c.hpp> +#include <boost/metaparse/v1/cpp98/impl/size.hpp> namespace boost { @@ -22,15 +21,10 @@ namespace boost template <class S, char C> struct push_back_c; -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs, char C> - struct push_back_c<string<Cs...>, C> : string<Cs..., C> {}; -#else template <class S, char C> struct push_back_c : update_c<typename S::type, size<typename S::type>::type::value, C> {}; -#endif } } } diff --git a/boost/metaparse/v1/impl/push_front_c.hpp b/boost/metaparse/v1/cpp98/impl/push_front_c.hpp index 27d0d3c7c9..0cf96a78a4 100644 --- a/boost/metaparse/v1/impl/push_front_c.hpp +++ b/boost/metaparse/v1/cpp98/impl/push_front_c.hpp @@ -1,13 +1,12 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_PUSH_FRONT_C_HPP -#define BOOST_METAPARSE_V1_IMPL_PUSH_FRONT_C_HPP +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_PUSH_FRONT_C_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_PUSH_FRONT_C_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> #include <boost/preprocessor/arithmetic/dec.hpp> #include <boost/preprocessor/repetition/enum_params.hpp> @@ -23,10 +22,6 @@ namespace boost template <class S, char C> struct push_front_c; -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs, char C> - struct push_front_c<string<Cs...>, C> : string<C, Cs...> {}; -#else template < BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C), char Ch @@ -43,7 +38,6 @@ namespace boost ) > {}; -#endif } } } diff --git a/boost/metaparse/v1/impl/size.hpp b/boost/metaparse/v1/cpp98/impl/size.hpp index c6e0ee7e27..7de124132a 100644 --- a/boost/metaparse/v1/impl/size.hpp +++ b/boost/metaparse/v1/cpp98/impl/size.hpp @@ -1,13 +1,12 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_SIZE_HPP -#define BOOST_METAPARSE_V1_IMPL_SIZE_HPP +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_SIZE_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_SIZE_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> #include <boost/mpl/int.hpp> @@ -29,10 +28,6 @@ namespace boost template <class S> struct size; -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs> - struct size<string<Cs...>> : boost::mpl::int_<sizeof...(Cs)> {}; -#else #ifdef BOOST_METAPARSE_STRING_CASE # error BOOST_METAPARSE_STRING_CASE #endif @@ -59,7 +54,6 @@ namespace boost ) #undef BOOST_METAPARSE_STRING_CASE -#endif } } } diff --git a/boost/metaparse/v1/impl/update_c.hpp b/boost/metaparse/v1/cpp98/impl/update_c.hpp index 5553933e95..367f79dc35 100644 --- a/boost/metaparse/v1/impl/update_c.hpp +++ b/boost/metaparse/v1/cpp98/impl/update_c.hpp @@ -1,15 +1,12 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_UPDATE_C_HPP -#define BOOST_METAPARSE_V1_IMPL_UPDATE_C_HPP +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_UPDATE_C_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_UPDATE_C_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/metaparse/v1/impl/split_at_c.hpp> -#include <boost/metaparse/v1/impl/concat.hpp> +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> #include <boost/preprocessor/arithmetic/dec.hpp> #include <boost/preprocessor/arithmetic/inc.hpp> @@ -27,7 +24,6 @@ namespace boost { namespace impl { -#ifndef BOOST_METAPARSE_VARIADIC_STRING template <class S, int N, int C> struct update_c; @@ -69,21 +65,6 @@ namespace boost #undef BOOST_METAPARSE_UPDATE #undef BOOST_METAPARSE_ARGN -#else - template <class S, int N, char C> - struct update_c : - concat< - typename split_at_c<N, S>::type::first, - typename - update_c<typename split_at_c<N, S>::type::second, 0, C>::type - > - {}; - - template <char... Cs, char C, char NewChar> - struct update_c<string<C, Cs...>, 0, NewChar> : - string<NewChar, Cs...> - {}; -#endif } } } diff --git a/boost/metaparse/v1/cpp98/string.hpp b/boost/metaparse/v1/cpp98/string.hpp new file mode 100644 index 0000000000..3f7ad7a555 --- /dev/null +++ b/boost/metaparse/v1/cpp98/string.hpp @@ -0,0 +1,272 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_STRING_HPP +#define BOOST_METAPARSE_V1_CPP98_STRING_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/metaparse/v1/cpp98/fwd/string.hpp> +#include <boost/metaparse/v1/string_tag.hpp> +#include <boost/metaparse/v1/impl/string_iterator.hpp> +#include <boost/metaparse/v1/cpp98/impl/empty_string.hpp> +#include <boost/metaparse/v1/cpp98/impl/size.hpp> +#include <boost/metaparse/v1/cpp98/impl/pop_front.hpp> +#include <boost/metaparse/v1/cpp98/impl/push_front_c.hpp> +#include <boost/metaparse/v1/cpp98/impl/push_back_c.hpp> +#include <boost/metaparse/v1/cpp98/impl/pop_back.hpp> + +#include <boost/preprocessor/arithmetic/sub.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/preprocessor/tuple/eat.hpp> + +#include <boost/type_traits/is_same.hpp> + +/* + * The string type + */ + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> + struct string + { + typedef string type; + typedef string_tag tag; + }; + } + } +} + +/* + * Boost.MPL overloads + */ + +namespace boost +{ + namespace mpl + { + // push_back + template <class S> + struct push_back_impl; + + template <> + struct push_back_impl<boost::metaparse::v1::string_tag> + { + typedef push_back_impl type; + + template <class S, class C> + struct apply : + boost::metaparse::v1::impl::push_back_c< + typename S::type, + C::type::value + > + {}; + }; + + // pop_back + template <class S> + struct pop_back_impl; + + template <> + struct pop_back_impl<boost::metaparse::v1::string_tag> + { + typedef pop_back_impl type; + + template <class S> + struct apply : boost::metaparse::v1::impl::pop_back<S> {}; + }; + + // push_front + template <class S> + struct push_front_impl; + + template <> + struct push_front_impl<boost::metaparse::v1::string_tag> + { + typedef push_front_impl type; + + template <class S, class C> + struct apply : + boost::metaparse::v1::impl::push_front_c< + typename S::type, + C::type::value + > + {}; + }; + + // pop_front + template <class S> + struct pop_front_impl; + + template <> + struct pop_front_impl<boost::metaparse::v1::string_tag> + { + typedef pop_front_impl type; + + template <class S> + struct apply : boost::metaparse::v1::impl::pop_front<S> {}; + }; + + // clear + template <class S> + struct clear_impl; + + template <> + struct clear_impl<boost::metaparse::v1::string_tag> + { + typedef clear_impl type; + + template <class S> + struct apply : boost::metaparse::v1::string<> {}; + }; + + // begin + template <class S> + struct begin_impl; + + template <> + struct begin_impl<boost::metaparse::v1::string_tag> + { + typedef begin_impl type; + + template <class S> + struct apply : + boost::metaparse::v1::impl::string_iterator<typename S::type, 0> + {}; + }; + + // end + template <class S> + struct end_impl; + + template <> + struct end_impl<boost::metaparse::v1::string_tag> + { + typedef end_impl type; + + template <class S> + struct apply : + boost::metaparse::v1::impl::string_iterator< + typename S::type, + boost::metaparse::v1::impl::size<typename S::type>::type::value + > + {}; + }; + + // equal_to + template <class A, class B> + struct equal_to_impl; + + template <> + struct equal_to_impl< + boost::metaparse::v1::string_tag, + boost::metaparse::v1::string_tag + > + { + typedef equal_to_impl type; + + template <class A, class B> + struct apply : boost::is_same<typename A::type, typename B::type> {}; + }; + + template <class T> + struct equal_to_impl<boost::metaparse::v1::string_tag, T> + { + typedef equal_to_impl type; + + template <class, class> + struct apply : false_ {}; + }; + + template <class T> + struct equal_to_impl<T, boost::metaparse::v1::string_tag> : + equal_to_impl<boost::metaparse::v1::string_tag, T> + {}; + + // c_str + template <class S> + struct c_str; + + template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> + struct c_str< + boost::metaparse::v1::string< + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) + > + > + { + typedef c_str type; + static const char value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1]; + }; + + template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> + const char + c_str< + boost::metaparse::v1::string< + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) + > + >::value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1] + = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0}; + + template <> + struct c_str<boost::metaparse::v1::string<> > : + boost::metaparse::v1::impl::empty_string<> + { + typedef c_str type; + }; + + #ifdef BOOST_METAPARSE_STRING_CASE + # error BOOST_METAPARSE_STRING_CASE is already defined + #endif + #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ + template <BOOST_PP_ENUM_PARAMS(n, int C)> \ + struct \ + c_str< \ + boost::metaparse::v1::string< \ + BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM( \ + BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ + BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ + ~ \ + ) \ + > \ + > \ + { \ + typedef c_str type; \ + static const char value[n + 1]; \ + }; \ + \ + template <BOOST_PP_ENUM_PARAMS(n, int C)> \ + const char c_str< \ + boost::metaparse::v1::string< \ + BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM( \ + BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ + BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ + ~ \ + ) \ + > \ + >::value[n + 1] = {BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) 0}; + + BOOST_PP_REPEAT_FROM_TO( + 1, + BOOST_METAPARSE_LIMIT_STRING_SIZE, + BOOST_METAPARSE_STRING_CASE, + ~ + ) + + #undef BOOST_METAPARSE_STRING_CASE + } +} + +#define BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING 1 + +#endif + diff --git a/boost/metaparse/v1/fwd/string.hpp b/boost/metaparse/v1/fwd/string.hpp index b5ecbd21e4..ea769d1bcd 100644 --- a/boost/metaparse/v1/fwd/string.hpp +++ b/boost/metaparse/v1/fwd/string.hpp @@ -1,38 +1,18 @@ #ifndef BOOST_METAPARSE_V1_FWD_STRING_HPP #define BOOST_METAPARSE_V1_FWD_STRING_HPP -// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2017. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/metaparse/config.hpp> -#include <boost/metaparse/limit_string_size.hpp> -#include <boost/metaparse/v1/impl/no_char.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -namespace boost -{ - namespace metaparse - { - namespace v1 - { -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs> - struct string; +#if BOOST_METAPARSE_STD >= 2011 +# include <boost/metaparse/v1/cpp11/fwd/string.hpp> #else - template < - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - BOOST_METAPARSE_LIMIT_STRING_SIZE, - int C, - BOOST_NO_CHAR - ) - > - struct string; +# include <boost/metaparse/v1/cpp98/fwd/string.hpp> #endif - } - } -} #endif diff --git a/boost/metaparse/v1/impl/at_c.hpp b/boost/metaparse/v1/impl/at_c.hpp index af7177410e..007ae18255 100644 --- a/boost/metaparse/v1/impl/at_c.hpp +++ b/boost/metaparse/v1/impl/at_c.hpp @@ -7,60 +7,12 @@ // http://www.boost.org/LICENSE_1_0.txt) #include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/mpl/char.hpp> - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/repeat.hpp> - -namespace boost -{ - namespace metaparse - { - namespace v1 - { - namespace impl - { - template <class S, int N> - struct at_c; - -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char C, char... Cs, int N> - struct at_c<string<C, Cs...>, N> : at_c<string<Cs...>, N - 1> {}; - - template <char C, char... Cs> - struct at_c<string<C, Cs...>, 0> : boost::mpl::char_<C> {}; +#if BOOST_METAPARSE_STD >= 2011 +# include <boost/metaparse/v1/cpp11/impl/at_c.hpp> #else - #ifdef BOOST_METAPARSE_STRING_CASE - # error BOOST_METAPARSE_STRING_CASE is already defined - #endif - #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ - template < \ - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C) \ - > \ - struct \ - at_c< \ - string< \ - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) \ - >, \ - n \ - > : \ - boost::mpl::char_<BOOST_PP_CAT(C, n)> \ - {}; - - BOOST_PP_REPEAT( - BOOST_METAPARSE_LIMIT_STRING_SIZE, - BOOST_METAPARSE_STRING_CASE, - ~ - ) - - #undef BOOST_METAPARSE_STRING_CASE +# include <boost/metaparse/v1/cpp98/impl/at_c.hpp> #endif - } - } - } -} #endif diff --git a/boost/metaparse/v1/impl/concat.hpp b/boost/metaparse/v1/impl/concat.hpp deleted file mode 100644 index d866ae42b1..0000000000 --- a/boost/metaparse/v1/impl/concat.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_CONCAT_HPP -#define BOOST_METAPARSE_V1_IMPL_CONCAT_HPP - -// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> - -#include <boost/preprocessor/arithmetic/dec.hpp> -#include <boost/preprocessor/arithmetic/inc.hpp> -#include <boost/preprocessor/arithmetic/mul.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> - -namespace boost -{ - namespace metaparse - { - namespace v1 - { - namespace impl - { - template <class A, class B> - struct concat; - -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... As, char... Bs> - struct concat<string<As...>, string<Bs...>> : string<As..., Bs...> {}; -#else - template <class A, class B> - struct concat_impl; - - #ifdef BOOST_METAPARSE_ARG - # error BOOST_METAPARSE_ARG already defined - #endif - #define BOOST_METAPARSE_ARG(z, n, unused) \ - BOOST_PP_CAT(B, BOOST_PP_INC(n)) - - #ifdef BOOST_METAPARSE_CONCAT - # error BOOST_METAPARSE_CONCAT already defined - #endif - #define BOOST_METAPARSE_CONCAT(z, n, unused) \ - template < \ - BOOST_PP_ENUM_PARAMS(n, int A) BOOST_PP_COMMA_IF(n) \ - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int B) \ - > \ - struct \ - concat_impl< \ - string< \ - BOOST_PP_ENUM_PARAMS(n, A) \ - BOOST_PP_COMMA_IF( \ - BOOST_PP_MUL( \ - BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ - n \ - ) \ - ) \ - BOOST_PP_ENUM( \ - BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ - BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ - ~ \ - ) \ - >, \ - string< \ - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, B) \ - > \ - > : \ - concat< \ - string<BOOST_PP_ENUM_PARAMS(n, A) BOOST_PP_COMMA_IF(n) B0>, \ - string< \ - BOOST_PP_ENUM( \ - BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_STRING_SIZE), \ - BOOST_METAPARSE_ARG, \ - ~ \ - ) \ - > \ - > \ - {}; - - BOOST_PP_REPEAT( - BOOST_METAPARSE_LIMIT_STRING_SIZE, - BOOST_METAPARSE_CONCAT, - ~ - ) - - #undef BOOST_METAPARSE_ARG - #undef BOOST_METAPARSE_CONCAT - - template <class S> - struct concat<S, string<> > : S {}; - - template <class A, class B> - struct concat : concat_impl<A, B> {}; -#endif - } - } - } -} - -#endif - diff --git a/boost/metaparse/v1/impl/empty_string.hpp b/boost/metaparse/v1/impl/empty_string.hpp deleted file mode 100644 index 7b62496450..0000000000 --- a/boost/metaparse/v1/impl/empty_string.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_EMPTY_STRING_HPP -#define BOOST_METAPARSE_V1_IMPL_EMPTY_STRING_HPP - -// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include <boost/metaparse/config.hpp> - -namespace boost -{ - namespace metaparse - { - namespace v1 - { - namespace impl - { - template <class Ignore = int> - struct empty_string - { - typedef empty_string type; - - #ifdef BOOST_NO_CONSTEXPR_C_STR - static const char value[1]; - #else - static constexpr char value[1] = {0}; - #endif - }; - - #ifdef BOOST_NO_CONSTEXPR_C_STR - template <class Ignore> - const char empty_string<Ignore>::value[1] = {0}; - #else - template <class Ignore> - constexpr char empty_string<Ignore>::value[1]; - #endif - } - } - } -} - -#endif - diff --git a/boost/metaparse/v1/impl/split_at_c.hpp b/boost/metaparse/v1/impl/split_at_c.hpp deleted file mode 100644 index 8a5a1a3618..0000000000 --- a/boost/metaparse/v1/impl/split_at_c.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef BOOST_METAPARSE_V1_IMPL_SPLIT_AT_C_HPP -#define BOOST_METAPARSE_V1_IMPL_SPLIT_AT_C_HPP - -// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/metaparse/v1/impl/push_front_c.hpp> - -#include <boost/preprocessor/arithmetic/add.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/repeat.hpp> - -#include <boost/mpl/pair.hpp> - -namespace boost -{ - namespace metaparse - { - namespace v1 - { - namespace impl - { - template <int N, class S> - struct split_at_c; - -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <int N, char C, char... Cs> - struct split_at_c<N, string<C, Cs...>> : - boost::mpl::pair< - typename push_front_c< - typename split_at_c<N - 1, string<Cs...>>::type::first, - C - >::type, - typename split_at_c<N - 1, string<Cs...>>::type::second - > - {}; - - template <char C, char... Cs> - struct split_at_c<0, string<C, Cs...>> : - boost::mpl::pair<string<>, string<C, Cs...>> - {}; - - template <class S> - struct split_at_c<0, S> : boost::mpl::pair<string<>, S> {}; -#else - #ifdef BOOST_METAPARSE_ARG - # error BOOST_METAPARSE_ARG already defined - #endif - #define BOOST_METAPARSE_ARG(z, n, d) BOOST_PP_CAT(C, BOOST_PP_ADD(n, d)) - - #ifdef BOOST_METAPARSE_SPLIT_AT - # error BOOST_METAPARSE_SPLIT_AT already defined - #endif - #define BOOST_METAPARSE_SPLIT_AT(z, n, unused) \ - template < \ - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C) \ - > \ - struct \ - split_at_c< \ - n, \ - string<BOOST_PP_ENUM_PARAMS( \ - BOOST_METAPARSE_LIMIT_STRING_SIZE, C) \ - > \ - > : \ - boost::mpl::pair< \ - string<BOOST_PP_ENUM_PARAMS(n, C)>, \ - string< \ - BOOST_PP_ENUM( \ - BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ - BOOST_METAPARSE_ARG, \ - n \ - ) \ - > \ - > \ - {}; - - BOOST_PP_REPEAT( - BOOST_METAPARSE_LIMIT_STRING_SIZE, - BOOST_METAPARSE_SPLIT_AT, - ~ - ) - - #undef BOOST_METAPARSE_SPLIT_AT - #undef BOOST_METAPARSE_ARG -#endif - } - } - } -} - -#endif - diff --git a/boost/metaparse/v1/string.hpp b/boost/metaparse/v1/string.hpp index 6535d659d3..d8bb9f93e3 100644 --- a/boost/metaparse/v1/string.hpp +++ b/boost/metaparse/v1/string.hpp @@ -1,355 +1,17 @@ #ifndef BOOST_METAPARSE_V1_STRING_HPP #define BOOST_METAPARSE_V1_STRING_HPP -// Copyright Abel Sinkovics (abel@sinkovics.hu) 2012. +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2017. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/metaparse/config.hpp> -#include <boost/metaparse/v1/fwd/string.hpp> -#include <boost/metaparse/v1/string_tag.hpp> -#include <boost/metaparse/v1/impl/string_iterator.hpp> -#include <boost/metaparse/v1/impl/empty_string.hpp> -#include <boost/metaparse/v1/impl/size.hpp> -#include <boost/metaparse/v1/impl/pop_front.hpp> -#include <boost/metaparse/v1/impl/push_front_c.hpp> -#include <boost/metaparse/v1/impl/push_back_c.hpp> -#include <boost/metaparse/v1/impl/pop_back.hpp> -#include <boost/metaparse/v1/impl/assert_string_length.hpp> -#include <boost/metaparse/v1/impl/string_at.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/repeat_from_to.hpp> -#include <boost/preprocessor/tuple/eat.hpp> - -#include <boost/type_traits/is_same.hpp> - -/* - * The string type - */ - -namespace boost -{ - namespace metaparse - { - namespace v1 - { -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs> - struct string - { - typedef string type; - typedef string_tag tag; - }; +#if BOOST_METAPARSE_STD >= 2011 +# include <boost/metaparse/v1/cpp11/string.hpp> #else - template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> - struct string - { - typedef string type; - typedef string_tag tag; - }; -#endif - } - } -} - -/* - * Boost.MPL overloads - */ - -namespace boost -{ - namespace mpl - { - // push_back - template <class S> - struct push_back_impl; - - template <> - struct push_back_impl<boost::metaparse::v1::string_tag> - { - typedef push_back_impl type; - - template <class S, class C> - struct apply : - boost::metaparse::v1::impl::push_back_c< - typename S::type, - C::type::value - > - {}; - }; - - // pop_back - template <class S> - struct pop_back_impl; - - template <> - struct pop_back_impl<boost::metaparse::v1::string_tag> - { - typedef pop_back_impl type; - - template <class S> - struct apply : boost::metaparse::v1::impl::pop_back<S> {}; - }; - - // push_front - template <class S> - struct push_front_impl; - - template <> - struct push_front_impl<boost::metaparse::v1::string_tag> - { - typedef push_front_impl type; - - template <class S, class C> - struct apply : - boost::metaparse::v1::impl::push_front_c< - typename S::type, - C::type::value - > - {}; - }; - - // pop_front - template <class S> - struct pop_front_impl; - - template <> - struct pop_front_impl<boost::metaparse::v1::string_tag> - { - typedef pop_front_impl type; - - template <class S> - struct apply : boost::metaparse::v1::impl::pop_front<S> {}; - }; - - // clear - template <class S> - struct clear_impl; - - template <> - struct clear_impl<boost::metaparse::v1::string_tag> - { - typedef clear_impl type; - - template <class S> - struct apply : boost::metaparse::v1::string<> {}; - }; - - // begin - template <class S> - struct begin_impl; - - template <> - struct begin_impl<boost::metaparse::v1::string_tag> - { - typedef begin_impl type; - - template <class S> - struct apply : - boost::metaparse::v1::impl::string_iterator<typename S::type, 0> - {}; - }; - - // end - template <class S> - struct end_impl; - - template <> - struct end_impl<boost::metaparse::v1::string_tag> - { - typedef end_impl type; - - template <class S> - struct apply : - boost::metaparse::v1::impl::string_iterator< - typename S::type, - boost::metaparse::v1::impl::size<typename S::type>::type::value - > - {}; - }; - - // equal_to - template <class A, class B> - struct equal_to_impl; - - template <> - struct equal_to_impl< - boost::metaparse::v1::string_tag, - boost::metaparse::v1::string_tag - > - { - typedef equal_to_impl type; - - template <class A, class B> - struct apply : boost::is_same<typename A::type, typename B::type> {}; - }; - - template <class T> - struct equal_to_impl<boost::metaparse::v1::string_tag, T> - { - typedef equal_to_impl type; - - template <class, class> - struct apply : false_ {}; - }; - - template <class T> - struct equal_to_impl<T, boost::metaparse::v1::string_tag> : - equal_to_impl<boost::metaparse::v1::string_tag, T> - {}; - - // c_str - template <class S> - struct c_str; - -#ifdef BOOST_METAPARSE_VARIADIC_STRING - template <char... Cs> - struct c_str<boost::metaparse::v1::string<Cs...>> - { - typedef c_str type; - #ifdef BOOST_NO_CONSTEXPR_C_STR - static const char value[sizeof...(Cs) + 1]; - #else - static constexpr char value[sizeof...(Cs) + 1] = {Cs..., 0}; - #endif - }; - - template <> - struct c_str<boost::metaparse::v1::string<>> : - boost::metaparse::v1::impl::empty_string<> - {}; - - #ifdef BOOST_NO_CONSTEXPR_C_STR - template <char... Cs> - const char c_str<boost::metaparse::v1::string<Cs...>>::value[] - = {Cs..., 0}; - #else - template <char... Cs> - constexpr char c_str<boost::metaparse::v1::string<Cs...>>::value[]; - #endif - -#else - template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> - struct c_str< - boost::metaparse::v1::string< - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) - > - > - { - typedef c_str type; - static BOOST_CONSTEXPR const char - value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1] - #if !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR - = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0} - #endif - ; - }; - - template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)> - BOOST_CONSTEXPR const char - c_str< - boost::metaparse::v1::string< - BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) - > - >::value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1] - #if defined BOOST_NO_CONSTEXPR || defined BOOST_NO_CXX11_CONSTEXPR - = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0} - #endif - ; - - template <> - struct c_str<boost::metaparse::v1::string<> > : - boost::metaparse::v1::impl::empty_string<> - { - typedef c_str type; - }; - - #ifdef BOOST_METAPARSE_DEF - # error BOOST_METAPARSE_DEF already defined - #endif - #define BOOST_METAPARSE_DEF(n) \ - = {BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) 0} - - #ifdef BOOST_METAPARSE_STRING_DECLARE - # error BOOST_METAPARSE_STRING_DECLARE already defined - #endif - #ifdef BOOST_METAPARSE_STRING_DEFINE - # error BOOST_METAPARSE_STRING_DECLARE already defined - #endif - #if !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR - # define BOOST_METAPARSE_STRING_DECLARE(n) BOOST_METAPARSE_DEF(n) - # define BOOST_METAPARSE_STRING_DEFINE(n) - #else - # define BOOST_METAPARSE_STRING_DECLARE(n) - # define BOOST_METAPARSE_STRING_DEFINE(n) BOOST_METAPARSE_DEF(n) - #endif - - #ifdef BOOST_METAPARSE_STRING_CASE - # error BOOST_METAPARSE_STRING_CASE is already defined - #endif - #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, int C)> \ - struct \ - c_str< \ - boost::metaparse::v1::string< \ - BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ - BOOST_PP_ENUM( \ - BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ - BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ - ~ \ - ) \ - > \ - > \ - { \ - typedef c_str type; \ - static BOOST_CONSTEXPR const char value[n + 1] \ - BOOST_METAPARSE_STRING_DECLARE(n); \ - }; \ - \ - template <BOOST_PP_ENUM_PARAMS(n, int C)> \ - BOOST_CONSTEXPR const char c_str< \ - boost::metaparse::v1::string< \ - BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ - BOOST_PP_ENUM( \ - BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ - BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ - ~ \ - ) \ - > \ - >::value[n + 1] BOOST_METAPARSE_STRING_DEFINE(n); - - BOOST_PP_REPEAT_FROM_TO( - 1, - BOOST_METAPARSE_LIMIT_STRING_SIZE, - BOOST_METAPARSE_STRING_CASE, - ~ - ) - - #undef BOOST_METAPARSE_STRING_CASE - #undef BOOST_METAPARSE_STRING_DECLARE - #undef BOOST_METAPARSE_STRING_DEFINE - #undef BOOST_METAPARSE_DEF -#endif - } -} - -#include <boost/metaparse/v1/impl/remove_trailing_no_chars.hpp> - -#if \ - defined BOOST_METAPARSE_VARIADIC_STRING \ - && !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR - -# include <boost/metaparse/v1/impl/string.hpp> - -#else - -# define BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING 1 - +# include <boost/metaparse/v1/cpp98/string.hpp> #endif #endif |