mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-07 15:08:22 +01:00
commit
8f2dcd3e21
22 changed files with 460 additions and 24 deletions
2
externals/mp/include/mp/metafunction/apply.h
vendored
2
externals/mp/include/mp/metafunction/apply.h
vendored
|
|
@ -1,4 +1,4 @@
|
|||
/* Ehis file is part of the mp project.
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
|
|
|||
20
externals/mp/include/mp/metavalue/bit_and.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/bit_and.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Bitwise and of metavalues Vs
|
||||
template<class... Vs>
|
||||
using bit_and = lift_value<(Vs::value & ...)>;
|
||||
|
||||
/// Bitwise and of metavalues Vs
|
||||
template<class... Vs>
|
||||
constexpr auto bit_and_v = (Vs::value & ...);
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/bit_not.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/bit_not.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Bitwise not of metavalue V
|
||||
template<class V>
|
||||
using bit_not = lift_value<~V::value>;
|
||||
|
||||
/// Bitwise not of metavalue V
|
||||
template<class V>
|
||||
constexpr auto bit_not_v = ~V::value;
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/bit_or.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/bit_or.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Bitwise or of metavalues Vs
|
||||
template<class... Vs>
|
||||
using bit_or = lift_value<(Vs::value | ...)>;
|
||||
|
||||
/// Bitwise or of metavalues Vs
|
||||
template<class... Vs>
|
||||
constexpr auto bit_or_v = (Vs::value | ...);
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/bit_xor.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/bit_xor.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Bitwise xor of metavalues Vs
|
||||
template<class... Vs>
|
||||
using bit_xor = lift_value<(Vs::value ^ ...)>;
|
||||
|
||||
/// Bitwise xor of metavalues Vs
|
||||
template<class... Vs>
|
||||
constexpr auto bit_xor_v = (Vs::value ^ ...);
|
||||
|
||||
} // namespace mp
|
||||
43
externals/mp/include/mp/metavalue/conjunction.h
vendored
Normal file
43
externals/mp/include/mp/metavalue/conjunction.h
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/value.h>
|
||||
#include <mp/metavalue/logic_if.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class...>
|
||||
struct conjunction_impl;
|
||||
|
||||
template<>
|
||||
struct conjunction_impl<> {
|
||||
using type = false_type;
|
||||
};
|
||||
|
||||
template<class V>
|
||||
struct conjunction_impl<V> {
|
||||
using type = V;
|
||||
};
|
||||
|
||||
template<class V1, class... Vs>
|
||||
struct conjunction_impl<V1, Vs...> {
|
||||
using type = logic_if<V1, typename conjunction_impl<Vs...>::type, V1>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Conjunction of metavalues Vs with short-circuiting and type preservation.
|
||||
template<class... Vs>
|
||||
using conjunction = typename detail::conjunction_impl<Vs...>::type;
|
||||
|
||||
/// Conjunction of metavalues Vs with short-circuiting and type preservation.
|
||||
template<class... Vs>
|
||||
constexpr auto conjunction_v = conjunction<Vs...>::value;
|
||||
|
||||
} // namespace mp
|
||||
43
externals/mp/include/mp/metavalue/disjunction.h
vendored
Normal file
43
externals/mp/include/mp/metavalue/disjunction.h
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/value.h>
|
||||
#include <mp/metavalue/logic_if.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class...>
|
||||
struct disjunction_impl;
|
||||
|
||||
template<>
|
||||
struct disjunction_impl<> {
|
||||
using type = false_type;
|
||||
};
|
||||
|
||||
template<class V>
|
||||
struct disjunction_impl<V> {
|
||||
using type = V;
|
||||
};
|
||||
|
||||
template<class V1, class... Vs>
|
||||
struct disjunction_impl<V1, Vs...> {
|
||||
using type = logic_if<V1, V1, typename disjunction_impl<Vs...>::type>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Disjunction of metavalues Vs with short-circuiting and type preservation.
|
||||
template<class... Vs>
|
||||
using disjunction = typename detail::disjunction_impl<Vs...>::type;
|
||||
|
||||
/// Disjunction of metavalues Vs with short-circuiting and type preservation.
|
||||
template<class... Vs>
|
||||
constexpr auto disjunction_v = disjunction<Vs...>::value;
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/logic_and.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/logic_and.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Logical conjunction of metavalues Vs without short-circuiting or type presevation.
|
||||
template<class... Vs>
|
||||
using logic_and = bool_value<(true && ... && Vs::value)>;
|
||||
|
||||
/// Logical conjunction of metavalues Vs without short-circuiting or type presevation.
|
||||
template<class... Vs>
|
||||
constexpr bool logic_and_v = (true && ... && Vs::value);
|
||||
|
||||
} // namespace mp
|
||||
21
externals/mp/include/mp/metavalue/logic_if.h
vendored
Normal file
21
externals/mp/include/mp/metavalue/logic_if.h
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Conditionally select between types T and F based on boolean metavalue V
|
||||
template<class V, class T, class F>
|
||||
using logic_if = std::conditional_t<bool(V::value), T, F>;
|
||||
|
||||
/// Conditionally select between metavalues T and F based on boolean metavalue V
|
||||
template<class V, class TV, class FV>
|
||||
constexpr auto logic_if_v = logic_if<V, TV, FV>::value;
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/logic_not.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/logic_not.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Logical negation of metavalue V.
|
||||
template<class V>
|
||||
using logic_not = bool_value<!bool(V::value)>;
|
||||
|
||||
/// Logical negation of metavalue V.
|
||||
template<class V>
|
||||
constexpr bool logic_not_v = !bool(V::value);
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/logic_or.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/logic_or.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Logical disjunction of metavalues Vs without short-circuiting or type presevation.
|
||||
template<class... Vs>
|
||||
using logic_or = bool_value<(false || ... || Vs::value)>;
|
||||
|
||||
/// Logical disjunction of metavalues Vs without short-circuiting or type presevation.
|
||||
template<class... Vs>
|
||||
constexpr bool logic_or_v = (false || ... || Vs::value);
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/product.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/product.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Product of metavalues Vs
|
||||
template<class... Vs>
|
||||
using product = lift_value<(Vs::value * ...)>;
|
||||
|
||||
/// Product of metavalues Vs
|
||||
template<class... Vs>
|
||||
constexpr auto product_v = (Vs::value * ...);
|
||||
|
||||
} // namespace mp
|
||||
20
externals/mp/include/mp/metavalue/sum.h
vendored
Normal file
20
externals/mp/include/mp/metavalue/sum.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// Sum of metavalues Vs
|
||||
template<class... Vs>
|
||||
using sum = lift_value<(Vs::value + ...)>;
|
||||
|
||||
/// Sum of metavalues Vs
|
||||
template<class... Vs>
|
||||
constexpr auto sum_v = (Vs::value + ...);
|
||||
|
||||
} // namespace mp
|
||||
31
externals/mp/include/mp/metavalue/value.h
vendored
Normal file
31
externals/mp/include/mp/metavalue/value.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
/// A metavalue (of type VT and value v).
|
||||
template<class VT, VT v>
|
||||
using value = std::integral_constant<VT, v>;
|
||||
|
||||
/// A metavalue of type std::size_t (and value v).
|
||||
template<std::size_t v>
|
||||
using size_value = value<std::size_t, v>;
|
||||
|
||||
/// A metavalue of type bool (and value v). (Aliases to std::bool_constant.)
|
||||
template<bool v>
|
||||
using bool_value = value<bool, v>;
|
||||
|
||||
/// true metavalue (Aliases to std::true_type).
|
||||
using true_type = bool_value<true>;
|
||||
|
||||
/// false metavalue (Aliases to std::false_type).
|
||||
using false_type = bool_value<false>;
|
||||
|
||||
} // namespace mp
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
namespace mp {
|
||||
|
||||
template<class F>
|
||||
struct function_info : public function_info<decltype(&F::operator())> {};
|
||||
struct function_info : function_info<decltype(&F::operator())> {};
|
||||
|
||||
template<class R, class... As>
|
||||
struct function_info<R(As...)> {
|
||||
|
|
@ -31,15 +31,15 @@ struct function_info<R(As...)> {
|
|||
};
|
||||
|
||||
template<class R, class... As>
|
||||
struct function_info<R(*)(As...)> : public function_info<R(As...)> {};
|
||||
struct function_info<R(*)(As...)> : function_info<R(As...)> {};
|
||||
|
||||
template<class C, class R, class... As>
|
||||
struct function_info<R(C::*)(As...)> : public function_info<R(As...)> {
|
||||
struct function_info<R(C::*)(As...)> : 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...)> {
|
||||
struct function_info<R(C::*)(As...) const> : function_info<R(As...)> {
|
||||
using class_type = C;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
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 {};
|
||||
struct is_instance_of_template : false_type {};
|
||||
|
||||
template <template <class...> class C, class... As>
|
||||
struct is_instance_of_template<C, C<As...>> : public std::true_type {};
|
||||
struct is_instance_of_template<C, C<As...>> : true_type {};
|
||||
|
||||
/// Is type T an instance of template class C?
|
||||
template<template <class...> class C, class T>
|
||||
|
|
|
|||
6
externals/mp/include/mp/typelist/contains.h
vendored
6
externals/mp/include/mp/typelist/contains.h
vendored
|
|
@ -1,11 +1,11 @@
|
|||
/* Ehis file is part of the mp project.
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2017 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <mp/metavalue/value.h>
|
||||
|
||||
namespace mp {
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ 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>)>
|
||||
: bool_value<(false || ... || std::is_same_v<Ts, T>)>
|
||||
{};
|
||||
|
||||
/// Does list L contain an element which is same as type T?
|
||||
|
|
|
|||
34
externals/mp/include/mp/typelist/drop.h
vendored
Normal file
34
externals/mp/include/mp/typelist/drop.h
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<size_t N, class L>
|
||||
struct drop_impl;
|
||||
|
||||
template<size_t N, template<class...> class LT>
|
||||
struct drop_impl<N, LT<>> {
|
||||
using type = LT<>;
|
||||
};
|
||||
|
||||
template<size_t N, template<class...> class LT, class E1, class... Es>
|
||||
struct drop_impl<N, LT<E1, Es...>> {
|
||||
using type = std::conditional_t<N == 0, LT<E1, Es...>, typename drop_impl<N - 1, LT<Es...>>::type>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Drops the first N elements of list L
|
||||
template<std::size_t N, class L>
|
||||
using drop = typename detail::drop_impl<N, L>::type;
|
||||
|
||||
} // namespace mp
|
||||
Loading…
Add table
Add a link
Reference in a new issue