1 #ifndef BOOST_METAPARSE_V1_CPP11_NTH_OF_C_HPP 2 #define BOOST_METAPARSE_V1_CPP11_NTH_OF_C_HPP 3 4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2017. 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) 8 9 #include <boost/metaparse/v1/cpp11/impl/nth_of_c.hpp> 10 11 #include <boost/metaparse/v1/fail.hpp> 12 #include <boost/metaparse/v1/error/index_out_of_range.hpp> 13 14 #include <type_traits> 15 16 namespace boost 17 { 18 namespace metaparse 19 { 20 namespace v1 21 { 22 template <int N, class... Ps> 23 struct nth_of_c 24 { 25 typedef nth_of_c type; 26 27 template <class S, class Pos> 28 struct apply : 29 std::conditional< 30 (0 <= N && N < sizeof...(Ps)), 31 impl::nth_of_c<N, S, Pos, Ps...>, 32 typename fail<error::index_out_of_range<0, sizeof...(Ps) - 1, N>> 33 ::template apply<S, Pos> 34 >::type 35 {}; 36 }; 37 38 template <int N> 39 struct nth_of_c<N> : fail<error::index_out_of_range<0, -1, N>> {}; 40 } 41 } 42 } 43 44 #endif 45 46