forked from mpusz/mp-units
Merge branch 'master' into mag-value-t
This commit is contained in:
@@ -55,7 +55,7 @@ if(${projectPrefix}IWYU)
|
|||||||
MAX_LINE_LENGTH 120
|
MAX_LINE_LENGTH 120
|
||||||
NO_COMMENTS
|
NO_COMMENTS
|
||||||
)
|
)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(${projectPrefix}AS_SYSTEM_HEADERS ON)
|
set(${projectPrefix}AS_SYSTEM_HEADERS ON)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
15
conanfile.py
15
conanfile.py
@@ -70,6 +70,12 @@ class UnitsConan(ConanFile):
|
|||||||
(compiler == "msvc" and (version == "19.3" or version >= "19.30") and compiler.cppstd == 23)
|
(compiler == "msvc" and (version == "19.3" or version >= "19.30") and compiler.cppstd == 23)
|
||||||
return not std_support
|
return not std_support
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _use_range_v3(self):
|
||||||
|
compiler = self.settings.compiler
|
||||||
|
version = Version(self.settings.compiler.version)
|
||||||
|
return ("clang" in compiler and compiler.libcxx == "libc++" and version < "14.0")
|
||||||
|
|
||||||
def set_version(self):
|
def set_version(self):
|
||||||
content = tools.load(os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
|
content = tools.load(os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
|
||||||
version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1)
|
version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1)
|
||||||
@@ -79,9 +85,9 @@ class UnitsConan(ConanFile):
|
|||||||
compiler = self.settings.compiler
|
compiler = self.settings.compiler
|
||||||
version = Version(self.settings.compiler.version)
|
version = Version(self.settings.compiler.version)
|
||||||
if self._use_libfmt:
|
if self._use_libfmt:
|
||||||
self.requires("fmt/8.0.1")
|
self.requires("fmt/8.1.1")
|
||||||
|
|
||||||
if compiler == "clang" and compiler.libcxx == "libc++" and version < "14.0":
|
if self._use_range_v3:
|
||||||
self.requires("range-v3/0.11.0")
|
self.requires("range-v3/0.11.0")
|
||||||
|
|
||||||
def build_requirements(self):
|
def build_requirements(self):
|
||||||
@@ -100,6 +106,9 @@ class UnitsConan(ConanFile):
|
|||||||
elif compiler == "clang":
|
elif compiler == "clang":
|
||||||
if version < "12":
|
if version < "12":
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least clang++-12")
|
raise ConanInvalidConfiguration("mp-units requires at least clang++-12")
|
||||||
|
elif compiler == "apple-clang":
|
||||||
|
if version < "13":
|
||||||
|
raise ConanInvalidConfiguration("mp-units requires at least AppleClang 13")
|
||||||
elif compiler == "Visual Studio":
|
elif compiler == "Visual Studio":
|
||||||
if version < "16":
|
if version < "16":
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least Visual Studio 16.9")
|
raise ConanInvalidConfiguration("mp-units requires at least Visual Studio 16.9")
|
||||||
@@ -148,7 +157,7 @@ class UnitsConan(ConanFile):
|
|||||||
self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"]
|
self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"]
|
||||||
if compiler == "Visual Studio":
|
if compiler == "Visual Studio":
|
||||||
self.cpp_info.components["core"].cxxflags = ["/utf-8"]
|
self.cpp_info.components["core"].cxxflags = ["/utf-8"]
|
||||||
elif compiler == "clang" and compiler.libcxx == "libc++":
|
if self._use_range_v3:
|
||||||
self.cpp_info.components["core"].requires.append("range-v3::range-v3")
|
self.cpp_info.components["core"].requires.append("range-v3::range-v3")
|
||||||
|
|
||||||
# rest
|
# rest
|
||||||
|
@@ -21,6 +21,7 @@ with a permissive `MIT license <https://github.com/mpusz/units/blob/master/LICEN
|
|||||||
- gcc-10
|
- gcc-10
|
||||||
- clang-12
|
- clang-12
|
||||||
- Visual Studio 16.9
|
- Visual Studio 16.9
|
||||||
|
- Apple clang 13
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
@@ -9,6 +9,7 @@ Installation And Usage
|
|||||||
- gcc-10
|
- gcc-10
|
||||||
- clang-12
|
- clang-12
|
||||||
- Visual Studio 16.9
|
- Visual Studio 16.9
|
||||||
|
- Apple clang 13
|
||||||
|
|
||||||
Repository Structure and Dependencies
|
Repository Structure and Dependencies
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
function(check_libcxx_in_use variable)
|
function(check_libcxx_in_use variable)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
message(CHECK_START "Checking if libc++ is being used")
|
message(CHECK_START "Checking if libc++ is being used")
|
||||||
list(APPEND CMAKE_MESSAGE_INDENT " ")
|
list(APPEND CMAKE_MESSAGE_INDENT " ")
|
||||||
|
|
||||||
|
@@ -37,14 +37,14 @@ check_libcxx_in_use(${projectPrefix}LIBCXX)
|
|||||||
add_library(mp-units-core INTERFACE)
|
add_library(mp-units-core INTERFACE)
|
||||||
target_compile_features(mp-units-core INTERFACE cxx_std_20)
|
target_compile_features(mp-units-core INTERFACE cxx_std_20)
|
||||||
target_link_libraries(mp-units-core INTERFACE
|
target_link_libraries(mp-units-core INTERFACE
|
||||||
gsl-lite::gsl-lite
|
gsl::gsl-lite
|
||||||
)
|
)
|
||||||
target_include_directories(mp-units-core ${unitsAsSystem} INTERFACE
|
target_include_directories(mp-units-core ${unitsAsSystem} INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
if(${projectPrefix}LIBCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
|
if(${projectPrefix}LIBCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
|
||||||
find_package(range-v3 CONFIG REQUIRED)
|
find_package(range-v3 CONFIG REQUIRED)
|
||||||
target_link_libraries(mp-units-core INTERFACE range-v3::range-v3)
|
target_link_libraries(mp-units-core INTERFACE range-v3::range-v3)
|
||||||
|
@@ -47,7 +47,7 @@ constexpr ratio inverse_if_negative(const ratio& r)
|
|||||||
template<Unit... Us, typename... Es>
|
template<Unit... Us, typename... Es>
|
||||||
constexpr ratio derived_ratio(exponent_list<Es...>)
|
constexpr ratio derived_ratio(exponent_list<Es...>)
|
||||||
{
|
{
|
||||||
return (... * inverse_if_negative<Es>(pow<detail::abs(Es::num)>(Us::ratio) / dimension_unit<typename Es::dimension>::ratio));
|
return (... * inverse_if_negative<Es>(pow<detail::abs(Es::num)>(Us::ratio / dimension_unit<typename Es::dimension>::ratio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<DerivedDimension D, Unit... Us>
|
template<DerivedDimension D, Unit... Us>
|
||||||
|
13
src/core/include/units/bits/external/hacks.h
vendored
13
src/core/include/units/bits/external/hacks.h
vendored
@@ -63,18 +63,13 @@
|
|||||||
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE UNITS_DIAGNOSTIC_IGNORE(4702)
|
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE UNITS_DIAGNOSTIC_IGNORE(4702)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UNITS_COMP_CLANG
|
|
||||||
|
|
||||||
#include <ciso646>
|
|
||||||
#if _LIBCPP_VERSION
|
#if _LIBCPP_VERSION
|
||||||
#define UNITS_LIBCXX _LIBCPP_VERSION
|
#define UNITS_LIBCXX _LIBCPP_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNITS_LIBCXX
|
#if UNITS_LIBCXX
|
||||||
|
|
||||||
#if UNITS_COMP_CLANG == 12
|
#if UNITS_LIBCXX < 13000
|
||||||
|
|
||||||
#include <concepts/concepts.hpp>
|
#include <concepts/concepts.hpp>
|
||||||
#include <range/v3/algorithm/lower_bound.hpp>
|
#include <range/v3/algorithm/lower_bound.hpp>
|
||||||
@@ -84,7 +79,7 @@
|
|||||||
#include <range/v3/iterator/concepts.hpp>
|
#include <range/v3/iterator/concepts.hpp>
|
||||||
#include <range/v3/range/concepts.hpp>
|
#include <range/v3/range/concepts.hpp>
|
||||||
|
|
||||||
#elif UNITS_COMP_CLANG == 13
|
#elif UNITS_LIBCXX < 14000
|
||||||
|
|
||||||
#include <range/v3/functional/comparisons.hpp>
|
#include <range/v3/functional/comparisons.hpp>
|
||||||
|
|
||||||
@@ -115,7 +110,7 @@ concept default_constructible = constructible_from<T>;
|
|||||||
|
|
||||||
#elif UNITS_LIBCXX
|
#elif UNITS_LIBCXX
|
||||||
|
|
||||||
#if UNITS_COMP_CLANG == 12
|
#if UNITS_LIBCXX < 13000
|
||||||
|
|
||||||
// concepts
|
// concepts
|
||||||
using concepts::common_with;
|
using concepts::common_with;
|
||||||
@@ -228,7 +223,7 @@ constexpr bool in_range(T t) noexcept
|
|||||||
std::cmp_less_equal(t, std::numeric_limits<R>::max());
|
std::cmp_less_equal(t, std::numeric_limits<R>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif UNITS_COMP_CLANG == 13
|
#elif UNITS_LIBCXX < 14000
|
||||||
|
|
||||||
using concepts::three_way_comparable;
|
using concepts::three_way_comparable;
|
||||||
using concepts::three_way_comparable_with;
|
using concepts::three_way_comparable_with;
|
||||||
|
@@ -363,16 +363,6 @@ concept Magnitude = detail::is_magnitude<T>;
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
T get_value(Magnitude auto m) { return m.template value<T>; }
|
T get_value(Magnitude auto m) { return m.template value<T>; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert any positive integer to a Magnitude.
|
|
||||||
*
|
|
||||||
* This will be the main way end users create Magnitudes. They should rarely (if ever) create a magnitude<...> by
|
|
||||||
* manually adding base powers.
|
|
||||||
*/
|
|
||||||
template<ratio R>
|
|
||||||
requires (R.num > 0)
|
|
||||||
constexpr Magnitude auto as_magnitude();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A base to represent pi.
|
* @brief A base to represent pi.
|
||||||
*/
|
*/
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
function(__check_libcxx_in_use variable)
|
function(__check_libcxx_in_use variable)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
message(CHECK_START "Checking if libc++ is being used")
|
message(CHECK_START "Checking if libc++ is being used")
|
||||||
list(APPEND CMAKE_MESSAGE_INDENT " ")
|
list(APPEND CMAKE_MESSAGE_INDENT " ")
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ find_dependency(fmt)
|
|||||||
find_dependency(gsl-lite)
|
find_dependency(gsl-lite)
|
||||||
|
|
||||||
# add range-v3 dependency only for clang + libc++
|
# add range-v3 dependency only for clang + libc++
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
__check_libcxx_in_use(__units_libcxx)
|
__check_libcxx_in_use(__units_libcxx)
|
||||||
if(__units_libcxx AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
|
if(__units_libcxx AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
|
||||||
find_dependency(range-v3)
|
find_dependency(range-v3)
|
||||||
|
@@ -59,6 +59,10 @@ static_assert(100_q_ft2 / 10_q_ft == 10_q_ft);
|
|||||||
|
|
||||||
static_assert(detail::unit_text<dim_area, square_foot>() == basic_symbol_text("ft²", "ft^2"));
|
static_assert(detail::unit_text<dim_area, square_foot>() == basic_symbol_text("ft²", "ft^2"));
|
||||||
|
|
||||||
|
// volume
|
||||||
|
static_assert(1_q_yd * 1_q_yd * 1_q_yd == 1_q_yd3);
|
||||||
|
static_assert(cubic_yard::ratio / cubic_foot::ratio == ratio(27));
|
||||||
|
|
||||||
/* ************** DERIVED DIMENSIONS WITH NAMED UNITS **************** */
|
/* ************** DERIVED DIMENSIONS WITH NAMED UNITS **************** */
|
||||||
|
|
||||||
// acceleration
|
// acceleration
|
||||||
|
Reference in New Issue
Block a user