mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-07 06:58:15 +01:00
Squashed 'externals/mp/' content from commit 29cb5588d
git-subtree-dir: externals/mp git-subtree-split: 29cb5588da3a18ed571a0e41622900a01b9f01eb
This commit is contained in:
commit
7b0c47d3f0
30 changed files with 971 additions and 0 deletions
26
include/mp/metafunction/apply.h
Normal file
26
include/mp/metafunction/apply.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Ehis file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<template<class...> class F, class L>
|
||||
struct apply_impl;
|
||||
|
||||
template<template<class...> class F, template<class...> class LT, class... Es>
|
||||
struct apply_impl<F, LT<Es...>> {
|
||||
using type = F<Es...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Invokes metafunction F where the arguments are all the members of list L
|
||||
template<template<class...> class F, class L>
|
||||
using apply = typename detail::apply_impl<F, L>::type;
|
||||
|
||||
} // namespace mp
|
||||
19
include/mp/metafunction/bind.h
Normal file
19
include/mp/metafunction/bind.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Binds the first sizeof...(A) arguments of metafunction F with arguments A
|
||||
template<template<class...> class F, class... As>
|
||||
struct bind {
|
||||
template<class... Rs>
|
||||
using type = F<As..., Rs...>;
|
||||
};
|
||||
|
||||
} // namespace mp
|
||||
|
||||
#define MM_MP_BIND(...) ::mp::bind<__VA_ARGS__>::template type
|
||||
23
include/mp/metafunction/identity.h
Normal file
23
include/mp/metafunction/identity.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct identity_impl {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Identity metafunction
|
||||
template<class T>
|
||||
using identity = typename identity_impl<T>::type;
|
||||
|
||||
} // namespace mp
|
||||
26
include/mp/metafunction/map.h
Normal file
26
include/mp/metafunction/map.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<template<class...> class F, class L>
|
||||
struct map_impl;
|
||||
|
||||
template<template<class...> class F, template<class...> class LT, class... Es>
|
||||
struct map_impl<F, LT<Es...>> {
|
||||
using type = LT<F<Es>...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Applies each element of list L to metafunction F
|
||||
template<template<class...> class F, class L>
|
||||
using map = typename detail::map_impl<F, L>::type;
|
||||
|
||||
} // namespace mp
|
||||
16
include/mp/metavalue/lift_value.h
Normal file
16
include/mp/metavalue/lift_value.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Lifts a value into a type (a metavalue)
|
||||
template<auto V>
|
||||
using lift_value = std::integral_constant<decltype(V), V>;
|
||||
|
||||
} // namespace mp
|
||||
16
include/mp/metavalue/value_cast.h
Normal file
16
include/mp/metavalue/value_cast.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Casts a metavalue from one type to another
|
||||
template<class T, class V>
|
||||
using value_cast = std::integral_constant<T, static_cast<T>(V::value)>;
|
||||
|
||||
} // namespace mp
|
||||
16
include/mp/metavalue/value_equal.h
Normal file
16
include/mp/metavalue/value_equal.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Do two metavalues contain the same value?
|
||||
template<class V1, class V2>
|
||||
using value_equal = std::bool_constant<V1::value == V2::value>;
|
||||
|
||||
} // namespace mp
|
||||
20
include/mp/misc/argument_count.h
Normal file
20
include/mp/misc/argument_count.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Metafunction that returns the number of arguments it has
|
||||
template<typename... Ts>
|
||||
using argument_count = lift_value<sizeof...(Ts)>;
|
||||
|
||||
/// Metafunction that returns the number of arguments it has
|
||||
template<typename... Ts>
|
||||
constexpr auto argument_count_v = sizeof...(Ts);
|
||||
|
||||
} // namespace mp
|
||||
64
include/mp/traits/function_info.h
Normal file
64
include/mp/traits/function_info.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
|
||||
#include <mp/typelist/list.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
template<class F>
|
||||
struct function_info : public function_info<decltype(&F::operator())> {};
|
||||
|
||||
template<class R, class... As>
|
||||
struct function_info<R(As...)> {
|
||||
using return_type = R;
|
||||
using parameter_list = list<As...>;
|
||||
static constexpr std::size_t parameter_count = sizeof...(As);
|
||||
|
||||
using equivalent_function_type = R(As...);
|
||||
|
||||
template<std::size_t I>
|
||||
struct parameter {
|
||||
static_assert(I < parameter_count, "Non-existent parameter");
|
||||
using type = std::tuple_element_t<I, std::tuple<As...>>;
|
||||
};
|
||||
};
|
||||
|
||||
template<class R, class... As>
|
||||
struct function_info<R(*)(As...)> : public function_info<R(As...)> {};
|
||||
|
||||
template<class C, class R, class... As>
|
||||
struct function_info<R(C::*)(As...)> : public function_info<R(As...)> {
|
||||
using class_type = C;
|
||||
};
|
||||
|
||||
template<class C, class R, class... As>
|
||||
struct function_info<R(C::*)(As...) const> : public function_info<R(As...)> {
|
||||
using class_type = C;
|
||||
};
|
||||
|
||||
template<class F>
|
||||
constexpr size_t parameter_count_v = function_info<F>::parameter_count;
|
||||
|
||||
template<class F>
|
||||
using parameter_list = typename function_info<F>::parameter_list;
|
||||
|
||||
template<class F, std::size_t I>
|
||||
using get_parameter = typename function_info<F>::template parameter<I>::type;
|
||||
|
||||
template<class F>
|
||||
using equivalent_function_type = typename function_info<F>::equivalent_function_type;
|
||||
|
||||
template<class F>
|
||||
using return_type = typename function_info<F>::return_type;
|
||||
|
||||
template<class F>
|
||||
using class_type = typename function_info<F>::class_type;
|
||||
|
||||
} // namespace mp
|
||||
50
include/mp/traits/integer_of_size.h
Normal file
50
include/mp/traits/integer_of_size.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t size>
|
||||
struct integer_of_size_impl{};
|
||||
|
||||
template<>
|
||||
struct integer_of_size_impl<8> {
|
||||
using unsigned_type = std::uint8_t;
|
||||
using signed_type = std::int8_t;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct integer_of_size_impl<16> {
|
||||
using unsigned_type = std::uint16_t;
|
||||
using signed_type = std::int16_t;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct integer_of_size_impl<32> {
|
||||
using unsigned_type = std::uint32_t;
|
||||
using signed_type = std::int32_t;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct integer_of_size_impl<64> {
|
||||
using unsigned_type = std::uint64_t;
|
||||
using signed_type = std::int64_t;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<std::size_t size>
|
||||
using unsigned_integer_of_size = typename detail::integer_of_size_impl<size>::unsigned_type;
|
||||
|
||||
template<std::size_t size>
|
||||
using signed_integer_of_size = typename detail::integer_of_size_impl<size>::signed_type;
|
||||
|
||||
} // namespace mp
|
||||
23
include/mp/traits/is_instance_of_template.h
Normal file
23
include/mp/traits/is_instance_of_template.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Is type T an instance of template class C?
|
||||
template <template <class...> class, class>
|
||||
struct is_instance_of_template : public std::false_type {};
|
||||
|
||||
template <template <class...> class C, class... As>
|
||||
struct is_instance_of_template<C, C<As...>> : public std::true_type {};
|
||||
|
||||
/// Is type T an instance of template class C?
|
||||
template<template <class...> class C, class T>
|
||||
constexpr bool is_instance_of_template_v = is_instance_of_template<C, T>::value;
|
||||
|
||||
} // namespace mp
|
||||
26
include/mp/typelist/append.h
Normal file
26
include/mp/typelist/append.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class... L>
|
||||
struct append_impl;
|
||||
|
||||
template<template<class...> class LT, class... E1s, class... E2s>
|
||||
struct append_impl<LT<E1s...>, E2s...> {
|
||||
using type = LT<E1s..., E2s...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Append items E to list L
|
||||
template<class L, class... Es>
|
||||
using append = typename detail::append_impl<L, Es...>::type;
|
||||
|
||||
} // namespace mp
|
||||
50
include/mp/typelist/cartesian_product.h
Normal file
50
include/mp/typelist/cartesian_product.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metafunction/bind.h>
|
||||
#include <mp/metafunction/map.h>
|
||||
#include <mp/typelist/append.h>
|
||||
#include <mp/typelist/concat.h>
|
||||
#include <mp/typelist/list.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class... Ls>
|
||||
struct cartesian_product_impl;
|
||||
|
||||
template<class RL>
|
||||
struct cartesian_product_impl<RL> {
|
||||
using type = RL;
|
||||
};
|
||||
|
||||
template<template<class...> class LT, class... REs, class... E2s>
|
||||
struct cartesian_product_impl<LT<REs...>, LT<E2s...>> {
|
||||
using type = concat<
|
||||
map<MM_MP_BIND(append, REs), list<E2s...>>...
|
||||
>;
|
||||
};
|
||||
|
||||
template<class RL, class L2, class L3, class... Ls>
|
||||
struct cartesian_product_impl<RL, L2, L3, Ls...> {
|
||||
using type = typename cartesian_product_impl<
|
||||
typename cartesian_product_impl<RL, L2>::type,
|
||||
L3,
|
||||
Ls...
|
||||
>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Produces the cartesian product of a set of lists
|
||||
/// For example:
|
||||
/// cartesian_product<list<A, B>, list<D, E>> == list<list<A, D>, list<A, E>, list<B, D>, list<B, E>
|
||||
template<typename L1, typename... Ls>
|
||||
using cartesian_product = typename detail::cartesian_product_impl<map<list, L1>, Ls...>::type;
|
||||
|
||||
} // namespace mp
|
||||
56
include/mp/typelist/concat.h
Normal file
56
include/mp/typelist/concat.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/typelist/list.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class... Ls>
|
||||
struct concat_impl;
|
||||
|
||||
template<>
|
||||
struct concat_impl<> {
|
||||
using type = list<>;
|
||||
};
|
||||
|
||||
template<class L>
|
||||
struct concat_impl<L> {
|
||||
using type = L;
|
||||
};
|
||||
|
||||
template<template<class...> class LT, class... E1s, class... E2s, class... Ls>
|
||||
struct concat_impl<LT<E1s...>, LT<E2s...>, Ls...> {
|
||||
using type = typename concat_impl<LT<E1s..., E2s...>, Ls...>::type;
|
||||
};
|
||||
|
||||
template<template<class...> class LT,
|
||||
class... E1s, class... E2s, class... E3s, class... E4s, class... E5s, class... E6s, class... E7s, class... E8s,
|
||||
class... E9s, class... E10s, class... E11s, class... E12s, class... E13s, class... E14s, class... E15s, class... E16s,
|
||||
class... Ls>
|
||||
struct concat_impl<
|
||||
LT<E1s...>, LT<E2s...>, LT<E3s...>, LT<E4s...>, LT<E5s...>, LT<E6s...>, LT<E7s...>, LT<E8s...>,
|
||||
LT<E9s...>, LT<E10s...>, LT<E11s...>, LT<E12s...>, LT<E13s...>, LT<E14s...>, LT<E15s...>, LT<E16s...>,
|
||||
Ls...>
|
||||
{
|
||||
using type = typename concat_impl<
|
||||
LT<
|
||||
E1s..., E2s..., E3s..., E4s..., E5s..., E6s..., E7s..., E8s...,
|
||||
E9s..., E10s..., E11s..., E12s..., E13s..., E14s..., E15s..., E16s...
|
||||
>,
|
||||
Ls...
|
||||
>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Concatenate lists together
|
||||
template<class... Ls>
|
||||
using concat = typename detail::concat_impl<Ls...>::type;
|
||||
|
||||
} // namespace mp
|
||||
25
include/mp/typelist/contains.h
Normal file
25
include/mp/typelist/contains.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* Ehis file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Does list L contain an element which is same as type T?
|
||||
template<class L, class T>
|
||||
struct contains;
|
||||
|
||||
template<template<class...> class LT, class... Ts, class T>
|
||||
struct contains<LT<Ts...>, T>
|
||||
: public std::bool_constant<(false || ... || std::is_same_v<Ts, T>)>
|
||||
{};
|
||||
|
||||
/// Does list L contain an element which is same as type T?
|
||||
template<class L, class T>
|
||||
constexpr bool contains_v = contains<L, T>::value;
|
||||
|
||||
} // namespace mp
|
||||
19
include/mp/typelist/get.h
Normal file
19
include/mp/typelist/get.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
|
||||
#include <mp/metafunction/apply.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Get element I from list L
|
||||
template<std::size_t I, class L>
|
||||
using get = std::tuple_element_t<I, apply<std::tuple, L>>;
|
||||
|
||||
} // namespace mp
|
||||
26
include/mp/typelist/head.h
Normal file
26
include/mp/typelist/head.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class L>
|
||||
struct head_impl;
|
||||
|
||||
template<template<class...> class LT, class E1, class... Es>
|
||||
struct head_impl<LT<E1, Es...>> {
|
||||
using type = E1;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Gets the tail/cdr/all-but-the-first-element of list L
|
||||
template<class L>
|
||||
using head = typename detail::head_impl<L>::type;
|
||||
|
||||
} // namespace mp
|
||||
21
include/mp/typelist/length.h
Normal file
21
include/mp/typelist/length.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metafunction/apply.h>
|
||||
#include <mp/misc/argument_count.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Length of list L
|
||||
template<class L>
|
||||
using length = apply<argument_count, L>;
|
||||
|
||||
/// Length of list L
|
||||
template<class L>
|
||||
constexpr auto length_v = length<L>::value;
|
||||
|
||||
} // namespace mp
|
||||
30
include/mp/typelist/lift_sequence.h
Normal file
30
include/mp/typelist/lift_sequence.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <mp/typelist/list.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class VL>
|
||||
struct lift_sequence_impl;
|
||||
|
||||
template<class T, template <class, T...> class VLT, T... values>
|
||||
struct lift_sequence_impl<VLT<T, values...>> {
|
||||
using type = list<std::integral_constant<T, values>...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Lifts values in value list VL to create a type list.
|
||||
template<class VL>
|
||||
using lift_sequence = typename detail::lift_sequence_impl<VL>::type;
|
||||
|
||||
} // namespace mp
|
||||
14
include/mp/typelist/list.h
Normal file
14
include/mp/typelist/list.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Contains a list of types
|
||||
template<class... E>
|
||||
struct list {};
|
||||
|
||||
} // namespace mp
|
||||
25
include/mp/typelist/lower_to_tuple.h
Normal file
25
include/mp/typelist/lower_to_tuple.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Converts a list of metavalues to a tuple.
|
||||
template<class L>
|
||||
struct lower_to_tuple;
|
||||
|
||||
template<template<class...> class LT, class... Es>
|
||||
struct lower_to_tuple<LT<Es...>> {
|
||||
static constexpr auto value = std::make_tuple(static_cast<typename Es::value_type>(Es::value)...);
|
||||
};
|
||||
|
||||
/// Converts a list of metavalues to a tuple.
|
||||
template<class L>
|
||||
constexpr auto lower_to_tuple_v = lower_to_tuple<L>::value;
|
||||
|
||||
} // namespace mp
|
||||
26
include/mp/typelist/prepend.h
Normal file
26
include/mp/typelist/prepend.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class... L>
|
||||
struct prepend_impl;
|
||||
|
||||
template<template<class...> class LT, class... E1s, class... E2s>
|
||||
struct prepend_impl<LT<E1s...>, E2s...> {
|
||||
using type = LT<E2s..., E1s...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Prepend items E to list L
|
||||
template<class L, class... Es>
|
||||
using prepend = typename detail::prepend_impl<L, Es...>::type;
|
||||
|
||||
} // namespace mp
|
||||
26
include/mp/typelist/tail.h
Normal file
26
include/mp/typelist/tail.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class L>
|
||||
struct tail_impl;
|
||||
|
||||
template<template<class...> class LT, class E1, class... Es>
|
||||
struct tail_impl<LT<E1, Es...>> {
|
||||
using type = LT<Es...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Gets the first type of list L
|
||||
template<class L>
|
||||
using tail = typename detail::tail_impl<L>::type;
|
||||
|
||||
} // namespace mp
|
||||
Loading…
Add table
Add a link
Reference in a new issue