forked from boostorg/mp11
Put mp_front into its own file
This commit is contained in:
42
include/boost/mp11/detail/mp_front.hpp
Normal file
42
include/boost/mp11/detail/mp_front.hpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED
|
||||||
|
#define BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2015-2021 Peter Dimov.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
//
|
||||||
|
// See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/mp11/detail/mp_list.hpp>
|
||||||
|
#include <boost/mp11/utility.hpp>
|
||||||
|
#include <boost/mp11/detail/config.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace mp11
|
||||||
|
{
|
||||||
|
|
||||||
|
// mp_front<L>
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class L> struct mp_front_impl
|
||||||
|
{
|
||||||
|
// An error "no type named 'type'" here means that the argument to mp_front
|
||||||
|
// is either not a list, or is an empty list
|
||||||
|
};
|
||||||
|
|
||||||
|
template<template<class...> class L, class T1, class... T> struct mp_front_impl<L<T1, T...>>
|
||||||
|
{
|
||||||
|
using type = T1;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class L> using mp_front = typename detail::mp_front_impl<L>::type;
|
||||||
|
|
||||||
|
} // namespace mp11
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_MP11_DETAIL_MP_FRONT_HPP_INCLUDED
|
@@ -12,6 +12,7 @@
|
|||||||
#include <boost/mp11/detail/mp_list.hpp>
|
#include <boost/mp11/detail/mp_list.hpp>
|
||||||
#include <boost/mp11/detail/mp_is_list.hpp>
|
#include <boost/mp11/detail/mp_is_list.hpp>
|
||||||
#include <boost/mp11/detail/mp_append.hpp>
|
#include <boost/mp11/detail/mp_append.hpp>
|
||||||
|
#include <boost/mp11/detail/mp_front.hpp>
|
||||||
#include <boost/mp11/detail/config.hpp>
|
#include <boost/mp11/detail/config.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@@ -66,23 +67,7 @@ template<class L1, class L2> using mp_assign = typename detail::mp_assign_impl<L
|
|||||||
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
||||||
|
|
||||||
// mp_front<L>
|
// mp_front<L>
|
||||||
namespace detail
|
// in detail/mp_front.hpp
|
||||||
{
|
|
||||||
|
|
||||||
template<class L> struct mp_front_impl
|
|
||||||
{
|
|
||||||
// An error "no type named 'type'" here means that the argument to mp_front
|
|
||||||
// is either not a list, or is an empty list
|
|
||||||
};
|
|
||||||
|
|
||||||
template<template<class...> class L, class T1, class... T> struct mp_front_impl<L<T1, T...>>
|
|
||||||
{
|
|
||||||
using type = T1;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template<class L> using mp_front = typename detail::mp_front_impl<L>::type;
|
|
||||||
|
|
||||||
// mp_pop_front<L>
|
// mp_pop_front<L>
|
||||||
namespace detail
|
namespace detail
|
||||||
|
Reference in New Issue
Block a user