VS2019 support added
This commit is contained in:
1 parent
71e3dba69a
commit
b318e8d039
38 files changed
+253
-160
No files matched your search
@@ -67,7 +67,7 @@ quantity_point<D, U, Rep> common_quantity_point_impl(quantity<D, U, Rep>);
|
||||
|
||||
template<Quantity Q1, Quantity Q2, Scalar Rep = std::common_type_t<typename Q1::rep, typename Q2::rep>>
|
||||
requires equivalent_dim<typename Q1::dimension, typename Q2::dimension>
|
||||
using common_quantity = detail::common_quantity_impl<Q1, Q2, Rep>::type;
|
||||
using common_quantity = TYPENAME detail::common_quantity_impl<Q1, Q2, Rep>::type;
|
||||
|
||||
template<QuantityPoint QP1, QuantityPoint QP2>
|
||||
requires requires { typename common_quantity<typename QP1::quantity_type, typename QP2::quantity_type>; }
|
||||
@@ -76,7 +76,7 @@ using common_quantity_point = decltype(
|
||||
|
||||
} // namespace units
|
||||
|
||||
#if COMP_GCC >= 10
|
||||
#if COMP_MSVC || COMP_GCC >= 10
|
||||
|
||||
namespace std {
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ struct dim_unpack<exp<Dim, Num, Den>, ERest...> {
|
||||
|
||||
template<DerivedDimension Dim, std::intmax_t Num, std::intmax_t Den, Exponent... ERest>
|
||||
struct dim_unpack<exp<Dim, Num, Den>, ERest...> {
|
||||
using type = dim_unpack<exp<downcast_base_t<Dim>, Num, Den>, ERest...>::type;
|
||||
using type = TYPENAME dim_unpack<exp<downcast_base_t<Dim>, Num, Den>, ERest...>::type;
|
||||
};
|
||||
|
||||
template<Exponent... Es, std::intmax_t Num, std::intmax_t Den, Exponent... ERest>
|
||||
|
||||
@@ -97,13 +97,13 @@ struct downcast_dimension_impl<D> {
|
||||
|
||||
template<DerivedDimension D>
|
||||
struct downcast_dimension_impl<D> {
|
||||
using type = check_unknown<downcast<D>>::type;
|
||||
using type = TYPENAME check_unknown<downcast<D>>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension D>
|
||||
using downcast_dimension = detail::downcast_dimension_impl<D>::type;
|
||||
using downcast_dimension = TYPENAME detail::downcast_dimension_impl<D>::type;
|
||||
|
||||
// dim_invert
|
||||
namespace detail {
|
||||
@@ -133,7 +133,7 @@ struct dim_invert_impl<D> : dim_invert_impl<downcast_base_t<D>> {
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension D>
|
||||
using dim_invert = detail::dim_invert_impl<D>::type;
|
||||
using dim_invert = TYPENAME detail::dim_invert_impl<D>::type;
|
||||
|
||||
// dimension_multiply
|
||||
namespace detail {
|
||||
@@ -161,7 +161,7 @@ struct to_dimension<exp_list<exp<D, 1>>> {
|
||||
* dimension itself.
|
||||
*/
|
||||
template<Dimension D1, Dimension D2>
|
||||
using merge_dimension = to_dimension<typename dim_consolidate<type_list_merge_sorted<typename D1::exponents, typename D2::exponents, exp_less>>::type>::type;
|
||||
using merge_dimension = TYPENAME to_dimension<typename dim_consolidate<type_list_merge_sorted<typename D1::exponents, typename D2::exponents, exp_less>>::type>::type;
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct dimension_multiply_impl;
|
||||
@@ -178,7 +178,7 @@ struct dimension_multiply_impl<D1, D2> {
|
||||
|
||||
template<DerivedDimension D1, BaseDimension D2>
|
||||
struct dimension_multiply_impl<D1, D2> {
|
||||
using type = dimension_multiply_impl<D2, D1>::type;
|
||||
using type = TYPENAME dimension_multiply_impl<D2, D1>::type;
|
||||
};
|
||||
|
||||
template<DerivedDimension D1, DerivedDimension D2>
|
||||
@@ -189,10 +189,10 @@ struct dimension_multiply_impl<D1, D2> {
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
using dimension_multiply = detail::dimension_multiply_impl<D1, D2>::type;
|
||||
using dimension_multiply = TYPENAME detail::dimension_multiply_impl<D1, D2>::type;
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
using dimension_divide = detail::dimension_multiply_impl<D1, dim_invert<D2>>::type;
|
||||
using dimension_divide = TYPENAME detail::dimension_multiply_impl<D1, dim_invert<D2>>::type;
|
||||
|
||||
// dimension_sqrt
|
||||
namespace detail {
|
||||
@@ -212,7 +212,7 @@ struct dimension_sqrt_impl<derived_dimension_base<exp<D, 2>>> {
|
||||
|
||||
template<DerivedDimension D>
|
||||
struct dimension_sqrt_impl<D> {
|
||||
using type = dimension_sqrt_impl<typename D::downcast_base_type>::type;
|
||||
using type = TYPENAME dimension_sqrt_impl<typename D::downcast_base_type>::type;
|
||||
};
|
||||
|
||||
template<typename... Es>
|
||||
@@ -223,7 +223,7 @@ struct dimension_sqrt_impl<derived_dimension_base<Es...>> {
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension D>
|
||||
using dimension_sqrt = detail::dimension_sqrt_impl<D>::type;
|
||||
using dimension_sqrt = TYPENAME detail::dimension_sqrt_impl<D>::type;
|
||||
|
||||
// dimension_pow
|
||||
namespace detail {
|
||||
@@ -248,7 +248,7 @@ struct dimension_pow_impl<derived_dimension_base<exp<D, 1, N>>, N> {
|
||||
|
||||
template<DerivedDimension D, std::intmax_t N>
|
||||
struct dimension_pow_impl<D, N> {
|
||||
using type = dimension_pow_impl<downcast_base_t<D>, N>::type;
|
||||
using type = TYPENAME dimension_pow_impl<downcast_base_t<D>, N>::type;
|
||||
};
|
||||
|
||||
template<typename... Es, std::intmax_t N>
|
||||
@@ -259,6 +259,6 @@ struct dimension_pow_impl<derived_dimension_base<Es...>, N> {
|
||||
} // namespace detail
|
||||
|
||||
template<Dimension D, std::intmax_t N>
|
||||
using dimension_pow = detail::dimension_pow_impl<D, N>::type;
|
||||
using dimension_pow = TYPENAME detail::dimension_pow_impl<D, N>::type;
|
||||
|
||||
} // namespace units
|
||||
+1
-1
@@ -68,6 +68,6 @@ template<Downcastable T>
|
||||
using downcast = decltype(detail::downcast_impl<T>());
|
||||
|
||||
template<Downcastable T>
|
||||
using downcast_base_t = T::downcast_base_type;
|
||||
using downcast_base_t = TYPENAME T::downcast_base_type;
|
||||
|
||||
} // namespace units
|
||||
+15
-9
@@ -22,9 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
|
||||
#if COMP_MSVC || COMP_GCC >= 10
|
||||
#include <compare>
|
||||
#endif
|
||||
|
||||
namespace units {
|
||||
|
||||
/**
|
||||
@@ -70,20 +76,20 @@ struct basic_fixed_string {
|
||||
return basic_fixed_string<CharT, N + N2>(txt);
|
||||
}
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
#if COMP_MSVC || COMP_GCC >= 10
|
||||
|
||||
template<typename CharT2, std::size_t N2>
|
||||
[[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs,
|
||||
const basic_fixed_string<CharT2, N2>& rhs)
|
||||
[[nodiscard]] constexpr bool operator==(const basic_fixed_string& other) const
|
||||
{
|
||||
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
return std::ranges::equal(*this, other);
|
||||
}
|
||||
|
||||
template<typename CharT2, std::size_t N2>
|
||||
[[nodiscard]] friend constexpr bool operator==(const basic_fixed_string& lhs,
|
||||
const basic_fixed_string<CharT2, N2>& rhs)
|
||||
template<std::size_t N2>
|
||||
[[nodiscard]] friend constexpr bool operator==(const basic_fixed_string&, const basic_fixed_string<CharT, N2>&) { return false; }
|
||||
|
||||
template<std::size_t N2>
|
||||
[[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs, const basic_fixed_string<CharT, N2>& rhs)
|
||||
{
|
||||
return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
+16
-2
@@ -29,9 +29,11 @@
|
||||
#elif __GNUC__
|
||||
#define COMP_GCC __GNUC__
|
||||
#define COMP_GCC_MINOR __GNUC_MINOR__
|
||||
#elif _MSC_VER
|
||||
#define COMP_MSVC _MSC_VER
|
||||
#endif
|
||||
|
||||
#if COMP_GCC >= 10
|
||||
#if COMP_MSVC || COMP_GCC >= 10
|
||||
|
||||
#include <concepts>
|
||||
|
||||
@@ -42,7 +44,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if COMP_GCC >= 10 || COMP_CLANG >= 11
|
||||
#if COMP_MSVC || COMP_GCC >= 10 || COMP_CLANG >= 11
|
||||
|
||||
#define AUTO auto
|
||||
#define SAME_AS(T) std::same_as<T>
|
||||
@@ -54,8 +56,19 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if COMP_MSVC
|
||||
|
||||
#define TYPENAME typename
|
||||
|
||||
#else
|
||||
|
||||
#define TYPENAME
|
||||
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
|
||||
#if COMP_GCC
|
||||
#if COMP_GCC >= 10
|
||||
|
||||
template<class T>
|
||||
@@ -100,5 +113,6 @@ namespace std {
|
||||
concept regular_invocable = invocable<F, Args...>;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
+20
-11
@@ -24,6 +24,11 @@
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable:4296) // warning C4296: '<': expression is always false
|
||||
#endif //_MSC_VER
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace detail {
|
||||
@@ -54,7 +59,7 @@ struct type_list_push_front_impl<List<OldTypes...>, NewTypes...> {
|
||||
} // namespace detail
|
||||
|
||||
template<TypeList List, typename... Types>
|
||||
using type_list_push_front = detail::type_list_push_front_impl<List, Types...>::type;
|
||||
using type_list_push_front = TYPENAME detail::type_list_push_front_impl<List, Types...>::type;
|
||||
|
||||
// push_back
|
||||
|
||||
@@ -71,7 +76,7 @@ struct type_list_push_back_impl<List<OldTypes...>, NewTypes...> {
|
||||
} // namespace detail
|
||||
|
||||
template<TypeList List, typename... Types>
|
||||
using type_list_push_back = detail::type_list_push_back_impl<List, Types...>::type;
|
||||
using type_list_push_back = TYPENAME detail::type_list_push_back_impl<List, Types...>::type;
|
||||
|
||||
// join
|
||||
|
||||
@@ -84,13 +89,13 @@ struct type_list_join_impl {
|
||||
|
||||
template<template<typename...> typename List, typename... First, typename... Second, typename... Rest>
|
||||
struct type_list_join_impl<List<First...>, List<Second...>, Rest...> {
|
||||
using type = type_list_join_impl<List<First..., Second...>, Rest...>::type;
|
||||
using type = TYPENAME type_list_join_impl<List<First..., Second...>, Rest...>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<TypeList... Lists>
|
||||
using type_list_join = detail::type_list_join_impl<Lists...>::type;
|
||||
using type_list_join = TYPENAME detail::type_list_join_impl<Lists...>::type;
|
||||
|
||||
// split
|
||||
|
||||
@@ -125,8 +130,8 @@ template<template<typename...> typename List, std::size_t N, typename... Types>
|
||||
struct type_list_split<List<Types...>, N> {
|
||||
static_assert(N <= sizeof...(Types), "Invalid index provided");
|
||||
using split = detail::split_impl<List, 0, N, Types...>;
|
||||
using first_list = split::first_list;
|
||||
using second_list = split::second_list;
|
||||
using first_list = TYPENAME split::first_list;
|
||||
using second_list = TYPENAME split::second_list;
|
||||
};
|
||||
|
||||
// split_half
|
||||
@@ -169,7 +174,7 @@ struct type_list_merge_sorted_impl<List<Lhs1, LhsRest...>, List<Rhs1, RhsRest...
|
||||
} // namespace detail
|
||||
|
||||
template<TypeList SortedList1, TypeList SortedList2, template<typename, typename> typename Pred>
|
||||
using type_list_merge_sorted = detail::type_list_merge_sorted_impl<SortedList1, SortedList2, Pred>::type;
|
||||
using type_list_merge_sorted = TYPENAME detail::type_list_merge_sorted_impl<SortedList1, SortedList2, Pred>::type;
|
||||
|
||||
// sort
|
||||
|
||||
@@ -192,14 +197,18 @@ template<template<typename...> typename List, typename... Types, template<typena
|
||||
struct type_list_sort_impl<List<Types...>, Pred> {
|
||||
using types = List<Types...>;
|
||||
using split = type_list_split_half<List<Types...>>;
|
||||
using sorted_left = type_list_sort_impl<typename split::first_list, Pred>::type;
|
||||
using sorted_right = type_list_sort_impl<typename split::second_list, Pred>::type;
|
||||
using type = type_list_merge_sorted_impl<sorted_left, sorted_right, Pred>::type;
|
||||
using sorted_left = TYPENAME type_list_sort_impl<typename split::first_list, Pred>::type;
|
||||
using sorted_right = TYPENAME type_list_sort_impl<typename split::second_list, Pred>::type;
|
||||
using type = TYPENAME type_list_merge_sorted_impl<sorted_left, sorted_right, Pred>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
using type_list_sort = TYPENAME detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#endif //_MSC_VER
|
||||
+2
-1
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
@@ -44,7 +45,7 @@ struct conditional_impl<true> {
|
||||
} // namespace detail
|
||||
|
||||
template<bool B, typename T, typename F>
|
||||
using conditional = detail::conditional_impl<B>::template type<T, F>;
|
||||
using conditional = TYPENAME detail::conditional_impl<B>::template type<T, F>;
|
||||
|
||||
// is_same
|
||||
template<class T, class U>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -113,12 +113,12 @@ constexpr auto exp_list_with_named_units(exp_list<Es...>);
|
||||
template<Exponent Exp>
|
||||
constexpr auto exp_list_with_named_units(Exp)
|
||||
{
|
||||
using dim = Exp::dimension;
|
||||
using dim = TYPENAME Exp::dimension;
|
||||
if constexpr(dimension_unit<dim>::is_named) {
|
||||
return exp_list<Exp>();
|
||||
}
|
||||
else {
|
||||
using recipe = dim::recipe;
|
||||
using recipe = TYPENAME dim::recipe;
|
||||
return exp_list_with_named_units(recipe());
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ constexpr auto exp_list_with_named_units(exp_list<Es...>)
|
||||
template<Dimension Dim>
|
||||
constexpr auto derived_dimension_unit_text()
|
||||
{
|
||||
using recipe = Dim::recipe;
|
||||
using recipe = TYPENAME Dim::recipe;
|
||||
return derived_dimension_unit_text(exp_list_with_named_units(recipe()));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user