mp_front.hpp 1.1 KB

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