Library refactoring based on Walter Brown's feedback
This commit is contained in:
1 parent
2514b669c9
commit
4409fa01ca
17 files changed
+384
-346
No files matched your search
@@ -27,18 +27,21 @@
|
||||
|
||||
namespace mp {
|
||||
|
||||
namespace detail {
|
||||
namespace std_concepts {
|
||||
|
||||
namespace detail {
|
||||
template<class T, class U>
|
||||
concept bool SameHelper = std::is_same_v<T, U>;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
concept bool SameHelper = std::is_same_v<T, U>;
|
||||
}
|
||||
concept bool Same = detail::SameHelper<T, U>&& detail::SameHelper<U, T>;
|
||||
|
||||
template<class T, class U>
|
||||
concept bool Same = detail::SameHelper<T, U> && detail::SameHelper<U, T>;
|
||||
|
||||
template <class From, class To>
|
||||
concept bool ConvertibleTo = std::is_convertible_v<From, To> &&
|
||||
requires(From (&f)()) {
|
||||
static_cast<To>(f());
|
||||
};
|
||||
template<class From, class To>
|
||||
concept bool ConvertibleTo = std::is_convertible_v<From, To>&& requires(From (&f)())
|
||||
{
|
||||
static_cast<To>(f());
|
||||
};
|
||||
|
||||
} // namespace std_concepts
|
||||
} // namespace mp
|
||||
@@ -26,7 +26,9 @@
|
||||
#include <ratio>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mp {
|
||||
namespace units {
|
||||
|
||||
using namespace mp::std_concepts; // todo Remove when std::concepts will arrive
|
||||
|
||||
// static_sign
|
||||
|
||||
@@ -58,15 +60,15 @@ namespace mp {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_ratio : std::false_type {
|
||||
};
|
||||
template<typename T>
|
||||
struct is_ratio : std::false_type {
|
||||
};
|
||||
|
||||
template<intmax_t Num, intmax_t Den>
|
||||
struct is_ratio<std::ratio<Num, Den>> : std::true_type {
|
||||
};
|
||||
template<intmax_t Num, intmax_t Den>
|
||||
struct is_ratio<std::ratio<Num, Den>> : std::true_type {
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
concept bool Ratio = detail::is_ratio<T>::value;
|
||||
@@ -84,4 +86,4 @@ namespace mp {
|
||||
template<Ratio Ratio1, Ratio Ratio2>
|
||||
using common_ratio_t = typename common_ratio<Ratio1, Ratio2>::type;
|
||||
|
||||
} // namespace mp
|
||||
} // namespace units
|
||||
@@ -30,12 +30,14 @@ namespace mp {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_type_list : std::false_type {};
|
||||
struct is_type_list : std::false_type {
|
||||
};
|
||||
|
||||
template<template<typename...> typename T, typename... Types>
|
||||
struct is_type_list<T<Types...>> : std::true_type {};
|
||||
struct is_type_list<T<Types...>> : std::true_type {
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
concept bool TypeList = detail::is_type_list<T>::value;
|
||||
@@ -84,8 +86,8 @@ namespace mp {
|
||||
using base = split_impl<List, Idx + 1, N, Rest...>;
|
||||
using base_first = typename base::first_list;
|
||||
using base_second = typename base::second_list;
|
||||
using first_list = std::conditional_t<Idx<N, type_list_push_front_t<base_first, T>, base_first>;
|
||||
using second_list = std::conditional_t<Idx<N, base_second, type_list_push_front_t<base_second, T>>;
|
||||
using first_list = std::conditional_t < Idx<N, type_list_push_front_t<base_first, T>, base_first>;
|
||||
using second_list = std::conditional_t < Idx<N, base_second, type_list_push_front_t<base_second, T>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -133,10 +135,8 @@ namespace mp {
|
||||
struct type_list_merge_sorted<List<Lhs1, LhsRest...>, List<Rhs1, RhsRest...>, Pred> {
|
||||
using type = std::conditional_t<
|
||||
Pred<Lhs1, Rhs1>::value,
|
||||
type_list_push_front_t<type_list_merge_sorted_t<List<LhsRest...>, List<Rhs1, RhsRest...>, Pred>,
|
||||
Lhs1>,
|
||||
type_list_push_front_t<type_list_merge_sorted_t<List<Lhs1, LhsRest...>, List<RhsRest...>, Pred>,
|
||||
Rhs1>>;
|
||||
type_list_push_front_t<type_list_merge_sorted_t<List<LhsRest...>, List<Rhs1, RhsRest...>, Pred>, Lhs1>,
|
||||
type_list_push_front_t<type_list_merge_sorted_t<List<Lhs1, LhsRest...>, List<RhsRest...>, Pred>, Rhs1>>;
|
||||
};
|
||||
|
||||
// sort
|
||||
|
||||
Reference in new issue
Block a user