| 1 | #ifndef BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED |
| 2 | #define BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED |
| 3 | |
| 4 | // Copyright 2015-2023 Peter Dimov. |
| 5 | // |
| 6 | // Distributed under the Boost Software License, Version 1.0. |
| 7 | // |
| 8 | // See accompanying file LICENSE_1_0.txt or copy at |
| 9 | // http://www.boost.org/LICENSE_1_0.txt |
| 10 | |
| 11 | #include <boost/mp11/detail/mp_value.hpp> |
| 12 | #include <boost/mp11/detail/config.hpp> |
| 13 | |
| 14 | namespace boost |
| 15 | { |
| 16 | namespace mp11 |
| 17 | { |
| 18 | |
| 19 | // mp_front<L> |
| 20 | namespace detail |
| 21 | { |
| 22 | |
| 23 | template<class L> struct mp_front_impl |
| 24 | { |
| 25 | // An error "no type named 'type'" here means that the argument to mp_front |
| 26 | // is either not a list, or is an empty list |
| 27 | }; |
| 28 | |
| 29 | template<template<class...> class L, class T1, class... T> struct mp_front_impl<L<T1, T...>> |
| 30 | { |
| 31 | using type = T1; |
| 32 | }; |
| 33 | |
| 34 | #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO) |
| 35 | |
| 36 | template<template<auto...> class L, auto A1, auto... A> struct mp_front_impl<L<A1, A...>> |
| 37 | { |
| 38 | using type = mp_value<A1>; |
| 39 | }; |
| 40 | |
| 41 | #endif |
| 42 | |
| 43 | } // namespace detail |
| 44 | |
| 45 | template<class L> using mp_front = typename detail::mp_front_impl<L>::type; |
| 46 | |
| 47 | } // namespace mp11 |
| 48 | } // namespace boost |
| 49 | |
| 50 | #endif // #ifndef BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED |
| 51 | |