build: got rid of old clang hacks and range-v3 dependency

This commit is contained in:
Mateusz Pusz
2023-09-26 18:09:06 +02:00
parent 3b6a22d2c0
commit 25fee701a0
5 changed files with 2 additions and 236 deletions
+1 -12
View File
@@ -27,10 +27,6 @@ if(NOT TARGET gsl::gsl-lite)
find_package(gsl-lite CONFIG REQUIRED)
endif()
# check if libc++ is being used
include(CheckLibcxxInUse)
check_libcxx_in_use(${projectPrefix}LIBCXX)
# core library definition
add_library(
mp-units-core
@@ -78,14 +74,7 @@ target_include_directories(
$<INSTALL_INTERFACE:include>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(${projectPrefix}LIBCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
if(NOT TARGET range-v3::range-v3)
find_package(range-v3 CONFIG REQUIRED)
endif()
target_link_libraries(mp-units-core INTERFACE range-v3::range-v3)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(
mp-units-core
INTERFACE /utf-8 # Specifies both the source character set and the execution character set as UTF-8
+1 -143
View File
@@ -70,34 +70,10 @@
#define MP_UNITS_DIAGNOSTIC_IGNORE_DEPRECATED
#endif
#if _LIBCPP_VERSION
#define MP_UNITS_LIBCXX _LIBCPP_VERSION
#endif
#if MP_UNITS_LIBCXX
#if MP_UNITS_LIBCXX < 13000
#include <concepts/concepts.hpp>
#include <range/v3/algorithm/lower_bound.hpp>
#include <range/v3/algorithm/transform.hpp>
#include <range/v3/functional/comparisons.hpp>
#include <range/v3/iterator.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/range/concepts.hpp>
#elif MP_UNITS_LIBCXX < 14000
#include <range/v3/functional/comparisons.hpp>
#endif
#endif
#include <compare>
#include <concepts>
#if MP_UNITS_COMP_MSVC || (MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 16)
#if MP_UNITS_COMP_MSVC
#define MP_UNITS_TYPENAME typename
@@ -145,124 +121,6 @@ namespace std {
template<class T>
concept default_constructible = constructible_from<T>;
#elif MP_UNITS_LIBCXX
#if MP_UNITS_LIBCXX < 13000
// concepts
using concepts::common_with;
using concepts::constructible_from;
using concepts::convertible_to;
using concepts::copy_constructible;
using concepts::derived_from;
using concepts::equality_comparable;
using concepts::equality_comparable_with;
using concepts::integral;
using concepts::move_constructible;
using concepts::regular;
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
using concepts::totally_ordered;
using ranges::compare_three_way;
using ranges::input_iterator;
using ranges::iter_value_t;
using ranges::sentinel_for;
namespace ranges {
using ::ranges::begin;
using ::ranges::distance;
using ::ranges::end;
using ::ranges::input_range;
using ::ranges::range_value_t;
using ::ranges::lower_bound;
using ::ranges::transform;
} // namespace ranges
// missing in Range-v3
template<class T>
concept floating_point = std::is_floating_point_v<T>;
template<class T>
concept default_initializable =
std::constructible_from<T> && requires { T{}; } && requires { ::new (static_cast<void*>(nullptr)) T; };
template<class F, class... Args>
concept invocable = requires(F&& f, Args&&... args) { std::invoke(std::forward<F>(f), std::forward<Args>(args)...); };
template<class F, class... Args>
concept regular_invocable = invocable<F, Args...>;
template<class T, class U>
constexpr bool cmp_equal(T t, U u) noexcept
{
using UT = std::make_unsigned_t<T>;
using UU = std::make_unsigned_t<U>;
if constexpr (std::is_signed_v<T> == std::is_signed_v<U>)
return t == u;
else if constexpr (std::is_signed_v<T>)
return t < 0 ? false : UT(t) == u;
else
return u < 0 ? false : t == UU(u);
}
template<class T, class U>
constexpr bool cmp_not_equal(T t, U u) noexcept
{
return !cmp_equal(t, u);
}
template<class T, class U>
constexpr bool cmp_less(T t, U u) noexcept
{
using UT = std::make_unsigned_t<T>;
using UU = std::make_unsigned_t<U>;
if constexpr (std::is_signed_v<T> == std::is_signed_v<U>)
return t < u;
else if constexpr (std::is_signed_v<T>)
return t < 0 ? true : UT(t) < u;
else
return u < 0 ? false : t < UU(u);
}
template<class T, class U>
constexpr bool cmp_greater(T t, U u) noexcept
{
return cmp_less(u, t);
}
template<class T, class U>
constexpr bool cmp_less_equal(T t, U u) noexcept
{
return !cmp_greater(t, u);
}
template<class T, class U>
constexpr bool cmp_greater_equal(T t, U u) noexcept
{
return !cmp_less(t, u);
}
template<class R, class T>
constexpr bool in_range(T t) noexcept
{
return std::cmp_greater_equal(t, std::numeric_limits<R>::min()) &&
std::cmp_less_equal(t, std::numeric_limits<R>::max());
}
#elif MP_UNITS_LIBCXX < 14000
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
using ::ranges::compare_three_way;
#endif
#endif
} // namespace std