Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_METAPARSE_V1_CPP11_IMPL_NTH_OF_C_HPP
0002 #define BOOST_METAPARSE_V1_CPP11_IMPL_NTH_OF_C_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2017.
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/impl/nth_of_c_skip_remaining.hpp>
0010 
0011 #include <boost/metaparse/v1/is_error.hpp>
0012 #include <boost/metaparse/v1/get_remaining.hpp>
0013 #include <boost/metaparse/v1/get_position.hpp>
0014 #include <boost/metaparse/v1/get_result.hpp>
0015 
0016 #include <type_traits>
0017 
0018 namespace boost
0019 {
0020   namespace metaparse
0021   {
0022     namespace v1
0023     {
0024       namespace impl
0025       {
0026         template <int N, class S, class Pos, class... Ps>
0027         struct nth_of_c;
0028 
0029         template <int N, class S, class Pos, class P, class... Ps>
0030         struct nth_of_c<N, S, Pos, P, Ps...>
0031         {
0032         private:
0033           template <class NextResult>
0034           struct apply_unchecked :
0035             nth_of_c<
0036               N - 1,
0037               typename get_remaining<NextResult>::type,
0038               typename get_position<NextResult>::type,
0039               Ps...
0040             >
0041           {};
0042 
0043         public:
0044           typedef
0045             typename std::conditional<
0046               is_error<typename P::template apply<S, Pos>>::type::value,
0047               typename P::template apply<S, Pos>,
0048               apply_unchecked<typename P::template apply<S, Pos>>
0049             >::type::type
0050             type;
0051         };
0052 
0053         template <class P, class S, class Pos, class... Ps>
0054         struct nth_of_c<0, S, Pos, P, Ps...>
0055         {
0056         private:
0057           template <class NextResult>
0058           struct apply_unchecked :
0059             nth_of_c_skip_remaining<
0060               typename get_result<NextResult>::type,
0061               typename get_remaining<NextResult>::type,
0062               typename get_position<NextResult>::type,
0063               Ps...
0064             >
0065           {};
0066 
0067         public:
0068           typedef
0069             typename std::conditional<
0070               is_error<typename P::template apply<S, Pos>>::type::value,
0071               typename P::template apply<S, Pos>,
0072               apply_unchecked<typename P::template apply<S, Pos>>
0073             >::type::type
0074             type;
0075         };
0076       }
0077     }
0078   }
0079 }
0080 
0081 #endif
0082