Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:48

0001 #ifndef BOOST_METAPARSE_V1_CPP11_STRING_HPP
0002 #define BOOST_METAPARSE_V1_CPP11_STRING_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2012.
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/metaparse/v1/cpp11/fwd/string.hpp>
0010 #include <boost/metaparse/v1/string_tag.hpp>
0011 #include <boost/metaparse/v1/impl/string_iterator.hpp>
0012 #include <boost/metaparse/v1/cpp11/impl/empty_string.hpp>
0013 #include <boost/metaparse/v1/cpp11/impl/size.hpp>
0014 #include <boost/metaparse/v1/cpp11/impl/pop_front.hpp>
0015 #include <boost/metaparse/v1/cpp11/impl/push_front_c.hpp>
0016 #include <boost/metaparse/v1/cpp11/impl/push_back_c.hpp>
0017 #include <boost/metaparse/v1/cpp11/impl/pop_back.hpp>
0018 #include <boost/metaparse/v1/cpp11/impl/string_at.hpp>
0019 
0020 #include <type_traits>
0021 
0022 /*
0023  * The string type
0024  */
0025 
0026 namespace boost
0027 {
0028   namespace metaparse
0029   {
0030     namespace v1
0031     {
0032       template <char... Cs>
0033       struct string
0034       {
0035         typedef string type;
0036         typedef string_tag tag;
0037       };
0038     }
0039   }
0040 }
0041 
0042 /*
0043  * Boost.MPL overloads
0044  */
0045 
0046 namespace boost
0047 {
0048   namespace mpl
0049   {
0050     // push_back
0051     template <class S>
0052     struct push_back_impl;
0053 
0054     template <>
0055     struct push_back_impl<boost::metaparse::v1::string_tag>
0056     {
0057       typedef push_back_impl type;
0058 
0059       template <class S, class C>
0060       struct apply :
0061         boost::metaparse::v1::impl::push_back_c<
0062           typename S::type,
0063           C::type::value
0064         >
0065       {};
0066     };
0067 
0068     // pop_back
0069     template <class S>
0070     struct pop_back_impl;
0071 
0072     template <>
0073     struct pop_back_impl<boost::metaparse::v1::string_tag>
0074     {
0075       typedef pop_back_impl type;
0076 
0077       template <class S>
0078       struct apply : boost::metaparse::v1::impl::pop_back<S> {};
0079     };
0080 
0081     // push_front
0082     template <class S>
0083     struct push_front_impl;
0084 
0085     template <>
0086     struct push_front_impl<boost::metaparse::v1::string_tag>
0087     {
0088       typedef push_front_impl type;
0089 
0090       template <class S, class C>
0091       struct apply :
0092         boost::metaparse::v1::impl::push_front_c<
0093           typename S::type,
0094           C::type::value
0095         >
0096       {};
0097     };
0098 
0099     // pop_front
0100     template <class S>
0101     struct pop_front_impl;
0102 
0103     template <>
0104     struct pop_front_impl<boost::metaparse::v1::string_tag>
0105     {
0106       typedef pop_front_impl type;
0107 
0108       template <class S>
0109       struct apply : boost::metaparse::v1::impl::pop_front<S> {};
0110     };
0111 
0112     // clear
0113     template <class S>
0114     struct clear_impl;
0115 
0116     template <>
0117     struct clear_impl<boost::metaparse::v1::string_tag>
0118     {
0119       typedef clear_impl type;
0120 
0121       template <class S>
0122       struct apply : boost::metaparse::v1::string<> {};
0123     };
0124 
0125     // begin
0126     template <class S>
0127     struct begin_impl;
0128 
0129     template <>
0130     struct begin_impl<boost::metaparse::v1::string_tag>
0131     {
0132       typedef begin_impl type;
0133 
0134       template <class S>
0135       struct apply :
0136         boost::metaparse::v1::impl::string_iterator<typename S::type, 0>
0137       {};
0138     };
0139 
0140     // end
0141     template <class S>
0142     struct end_impl;
0143 
0144     template <>
0145     struct end_impl<boost::metaparse::v1::string_tag>
0146     {
0147       typedef end_impl type;
0148 
0149       template <class S>
0150       struct apply :
0151         boost::metaparse::v1::impl::string_iterator<
0152           typename S::type,
0153           boost::metaparse::v1::impl::size<typename S::type>::type::value
0154         >
0155       {};
0156     };
0157 
0158     // equal_to
0159     template <class A, class B>
0160     struct equal_to_impl;
0161 
0162     template <>
0163     struct equal_to_impl<
0164       boost::metaparse::v1::string_tag,
0165       boost::metaparse::v1::string_tag
0166     >
0167     {
0168       typedef equal_to_impl type;
0169 
0170       template <class A, class B>
0171       struct apply : std::is_same<typename A::type, typename B::type> {};
0172     };
0173 
0174     template <class T>
0175     struct equal_to_impl<boost::metaparse::v1::string_tag, T>
0176     {
0177       typedef equal_to_impl type;
0178       
0179       template <class, class>
0180       struct apply : false_ {};
0181     };
0182     
0183     template <class T>
0184     struct equal_to_impl<T, boost::metaparse::v1::string_tag> :
0185       equal_to_impl<boost::metaparse::v1::string_tag, T>
0186     {};
0187 
0188     // c_str
0189     template <class S>
0190     struct c_str;
0191 
0192     template <char... Cs>
0193     struct c_str<boost::metaparse::v1::string<Cs...>>
0194     {
0195       typedef c_str type;
0196       static constexpr char value[sizeof...(Cs) + 1] = {Cs..., 0};
0197     };
0198 
0199     template <>
0200     struct c_str<boost::metaparse::v1::string<>> :
0201       boost::metaparse::v1::impl::empty_string<>
0202     {};
0203 
0204     template <char... Cs>
0205     constexpr char c_str<boost::metaparse::v1::string<Cs...>>::value[];
0206   }
0207 }
0208 
0209 #if __clang__
0210 #  if __has_extension(cxx_string_literal_templates)
0211 #    define BOOST_METAPARSE_V1_STRING(...) ::boost::metaparse::string<__VA_ARGS__>
0212 #  else
0213 #    include <boost/metaparse/v1/cpp11/impl/string.hpp>
0214 #  endif
0215 #else
0216 #  include <boost/metaparse/v1/cpp11/impl/string.hpp>
0217 #endif
0218 
0219 #endif
0220