diff --git a/conanfile.py b/conanfile.py index 4463ad45..5a2467b4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -47,10 +47,11 @@ class UnitsConan(ConanFile): exports_sources = ["src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"] settings = "os", "compiler", "build_type", "arch" requires = ( - "range-v3/0.9.1@ericniebler/stable", - "Catch2/2.10.0@catchorg/stable", "fmt/6.0.0" ) + build_requires = ( + "Catch2/2.10.0@catchorg/stable" + ) generators = "cmake" @property @@ -73,6 +74,10 @@ class UnitsConan(ConanFile): cmake.configure(source_folder="src", build_folder="src") return cmake + def requirements(self): + if Version(self.settings.compiler.version) < "10": + self.requires("range-v3/0.10.0@ericniebler/stable") + def build(self): cmake = self._configure_cmake() cmake.build() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 389aac19..a8d69659 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,7 +53,6 @@ add_library(units INTERFACE) target_compile_features(units INTERFACE cxx_std_20) target_link_libraries(units INTERFACE - CONAN_PKG::range-v3 CONAN_PKG::fmt ) target_include_directories(units @@ -71,6 +70,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) -Wno-pedantic ) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + target_link_libraries(units + INTERFACE + CONAN_PKG::range-v3 + ) + target_compile_options(units INTERFACE -fconcepts diff --git a/src/include/units/bits/hacks.h b/src/include/units/bits/hacks.h index da702863..c1bb861a 100644 --- a/src/include/units/bits/hacks.h +++ b/src/include/units/bits/hacks.h @@ -22,7 +22,6 @@ #pragma once -#include #include #ifdef NDEBUG @@ -32,16 +31,24 @@ #define Expects(cond) assert(cond); #endif -#if __GNUC__ > 9 -#define AUTO auto -#define SAME_AS(T) std::same_as -#else +#if __GNUC__ < 10 + +#include #define AUTO #define SAME_AS(T) T + +#else + +#include +#define AUTO auto +#define SAME_AS(T) std::same_as + #endif namespace std { +#if __GNUC__ < 10 + // concepts using concepts::common_reference_with; using concepts::common_with; @@ -64,4 +71,11 @@ namespace std { template concept regular_invocable = invocable; -} +#else + +template +concept default_constructible = constructible_from; + +#endif + +} // namespace std diff --git a/src/include/units/math.h b/src/include/units/math.h index 4632b693..b9782c3f 100644 --- a/src/include/units/math.h +++ b/src/include/units/math.h @@ -28,8 +28,8 @@ namespace units { template - requires N == 0 - inline Rep AUTO pow(const quantity&) noexcept + requires (N == 0) + inline Rep pow(const quantity&) noexcept { return 1; } diff --git a/test/unit_test/static/dimension_op_test.cpp b/test/unit_test/static/dimension_op_test.cpp index b9d199c3..6f94c6b5 100644 --- a/test/unit_test/static/dimension_op_test.cpp +++ b/test/unit_test/static/dimension_op_test.cpp @@ -111,7 +111,7 @@ static_assert(std::is_same_v< unknown_dimension, exp>>); static_assert(std::is_same_v>, derived_dimension>>, unknown_dimension<>>); -static_assert(std::is_same_v>, unknown_dimension>>, d0>); +static_assert(std::is_same_v>, derived_dimension>>, d0>); // dimension_divide