forked from mpusz/mp-units
Merge branch 'master' of github.com:mpusz/units
This commit is contained in:
@@ -95,6 +95,7 @@ add_custom_command(OUTPUT "${SPHINX_INDEX_FILE}"
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/examples/linear_algebra.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/examples/linear_algebra.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/examples/measurement.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/examples/measurement.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/examples/total_energy.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/examples/total_energy.rst"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/examples/unknown_dimension.rst"
|
||||||
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/faq.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/faq.rst"
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ add_custom_command(OUTPUT "${SPHINX_INDEX_FILE}"
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/conversions_and_casting.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/conversions_and_casting.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/dimensions.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/dimensions.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantities.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantities.rst"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_points.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/text_output.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/text_output.rst"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/framework/units.rst"
|
"${CMAKE_CURRENT_SOURCE_DIR}/framework/units.rst"
|
||||||
|
|
||||||
|
@@ -51,8 +51,8 @@ naming and we came up with ``q_`` prefix which results in a creation of
|
|||||||
quantity of a provided unit.
|
quantity of a provided unit.
|
||||||
|
|
||||||
|
|
||||||
Why do we use UDLs reserved for the C++ standard (no `_` prefix)?
|
Why do we use UDLs reserved for the C++ standard (no ``_`` prefix)?
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
This library is meant to become a part of the C++ Standard Library at some point
|
This library is meant to become a part of the C++ Standard Library at some point
|
||||||
in the future. We decided to work with the target interface to get implementation
|
in the future. We decided to work with the target interface to get implementation
|
||||||
@@ -63,8 +63,8 @@ with literals already existing in the language in our initial approach
|
|||||||
This approach has some side effects though. We had to disable some compiler warnings
|
This approach has some side effects though. We had to disable some compiler warnings
|
||||||
to make it work:
|
to make it work:
|
||||||
|
|
||||||
- `/wd4455` on MSVC,
|
- ``/wd4455`` on MSVC,
|
||||||
- `-Wno-literal-suffix` on other compilers.
|
- ``-Wno-literal-suffix`` on other compilers.
|
||||||
|
|
||||||
|
|
||||||
Text formatting
|
Text formatting
|
||||||
|
@@ -261,7 +261,7 @@ differences:
|
|||||||
`the project's README file <https://github.com/mpusz/units/blob/master/README.md>`_ or on
|
`the project's README file <https://github.com/mpusz/units/blob/master/README.md>`_ or on
|
||||||
`the project's Bintray <https://bintray.com/mpusz/conan-mpusz/mp-units%3Ampusz>`_.
|
`the project's Bintray <https://bintray.com/mpusz/conan-mpusz/mp-units%3Ampusz>`_.
|
||||||
|
|
||||||
3. Force Conan to check for updated recipes `-u` and to build outdated packages `-b outdated`:
|
3. Force Conan to check for updated recipes ``-u`` and to build outdated packages ``-b outdated``:
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ enough to handle simple dependencies and configurations. If your project setup i
|
|||||||
may prefer to use ``cmake`` generator. In such a case the above procedures should be updated as
|
may prefer to use ``cmake`` generator. In such a case the above procedures should be updated as
|
||||||
follows:
|
follows:
|
||||||
|
|
||||||
1. Specify `cmake` generator in your Conan configuration file:
|
1. Specify ``cmake`` generator in your Conan configuration file:
|
||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
:caption: conanfile.txt
|
:caption: conanfile.txt
|
||||||
@@ -317,7 +317,7 @@ in **mp-units** repository, you should:
|
|||||||
1. Add remotes of additional Conan dependencies.
|
1. Add remotes of additional Conan dependencies.
|
||||||
2. Use the *CMakeLists.txt* from the top-level directory.
|
2. Use the *CMakeLists.txt* from the top-level directory.
|
||||||
3. Obtain Python dependencies.
|
3. Obtain Python dependencies.
|
||||||
4. Run Conan with :envvar:`CONAN_RUN_TESTS` = ``True``.
|
4. Run Conan with `CONAN_RUN_TESTS`_ = ``True``.
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
|
23
src/include/units/bits/external/type_traits.h
vendored
23
src/include/units/bits/external/type_traits.h
vendored
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <units/bits/external/hacks.h>
|
#include <units/bits/external/hacks.h>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
@@ -58,32 +59,22 @@ template<class T, class U>
|
|||||||
using is_same = std::bool_constant<is_same_v<T, U>>;
|
using is_same = std::bool_constant<is_same_v<T, U>>;
|
||||||
|
|
||||||
// is_specialization_of
|
// is_specialization_of
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
template<typename T, template<typename...> typename Type>
|
||||||
inline constexpr bool is_specialization_of_impl = false;
|
inline constexpr bool is_specialization_of = false;
|
||||||
|
|
||||||
template<typename... Params, template<typename...> typename Type>
|
template<typename... Params, template<typename...> typename Type>
|
||||||
inline constexpr bool is_specialization_of_impl<Type<Params...>, Type> = true;
|
inline constexpr bool is_specialization_of<Type<Params...>, Type> = true;
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
|
||||||
inline constexpr bool is_specialization_of = detail::is_specialization_of_impl<T, Type>;
|
|
||||||
|
|
||||||
// is_derived_from_specialization_of
|
// is_derived_from_specialization_of
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<template<typename...> typename Type>
|
template<template<typename...> typename Type, typename... Params>
|
||||||
struct is_derived_from_specialization_of_impl {
|
void to_base_specialization_of(const volatile Type<Params...>*);
|
||||||
template<typename... Params>
|
|
||||||
static constexpr std::true_type check_base(const Type<Params...>&);
|
|
||||||
static constexpr std::false_type check_base(...);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<typename T, template<typename...> typename Type>
|
template<typename T, template<typename...> typename Type>
|
||||||
inline constexpr bool is_derived_from_specialization_of = decltype(detail::is_derived_from_specialization_of_impl<Type>::check_base(std::declval<T>()))::value;
|
// inline constexpr bool // TODO: Replace with concept when it works with MSVC
|
||||||
|
concept is_derived_from_specialization_of = requires { detail::to_base_specialization_of<Type>(std::declval<const volatile T*>()); };
|
||||||
|
|
||||||
} // namespace units
|
} // namespace units
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
#include <units/ratio.h>
|
#include <units/ratio.h>
|
||||||
#include <units/bits/external/type_traits.h>
|
#include <units/bits/external/type_traits.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
@@ -84,14 +86,8 @@ struct scaled_unit;
|
|||||||
// TODO: Remove when P1985 accepted
|
// TODO: Remove when P1985 accepted
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct is_derived_from_scaled_unit_impl {
|
template<ratio R, typename U>
|
||||||
template<ratio R, typename U>
|
void to_base_scaled_unit(const volatile scaled_unit<R, U>*);
|
||||||
static constexpr std::true_type check_base(const scaled_unit<R, U>&);
|
|
||||||
static constexpr std::false_type check_base(...);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline constexpr bool is_derived_from_scaled_unit = decltype(is_derived_from_scaled_unit_impl::check_base(std::declval<T>()))::value;
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@@ -101,22 +97,17 @@ inline constexpr bool is_derived_from_scaled_unit = decltype(is_derived_from_sca
|
|||||||
* Satisfied by all unit types derived from an specialization of :class:`scaled_unit`.
|
* Satisfied by all unit types derived from an specialization of :class:`scaled_unit`.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Unit = detail::is_derived_from_scaled_unit<T>;
|
concept Unit = requires { detail::to_base_scaled_unit(std::declval<const volatile T*>()); };
|
||||||
|
|
||||||
|
// BaseDimension
|
||||||
template<basic_fixed_string Symbol, Unit U>
|
template<basic_fixed_string Symbol, Unit U>
|
||||||
requires U::is_named
|
requires U::is_named
|
||||||
struct base_dimension;
|
struct base_dimension;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct is_derived_from_base_dimension_impl {
|
template<basic_fixed_string Symbol, typename U>
|
||||||
template<basic_fixed_string Symbol, typename U>
|
void to_base_base_dimension(const volatile base_dimension<Symbol, U>*);
|
||||||
static constexpr std::true_type check_base(const base_dimension<Symbol, U>&);
|
|
||||||
static constexpr std::false_type check_base(...);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline constexpr bool is_derived_from_base_dimension = decltype(is_derived_from_base_dimension_impl::check_base(std::declval<T>()))::value;
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@@ -126,7 +117,7 @@ inline constexpr bool is_derived_from_base_dimension = decltype(is_derived_from_
|
|||||||
* Satisfied by all dimension types derived from an specialization of `base_dimension`.
|
* Satisfied by all dimension types derived from an specialization of `base_dimension`.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept BaseDimension = detail::is_derived_from_base_dimension<T>;
|
concept BaseDimension = requires { detail::to_base_base_dimension(std::declval<const volatile T*>()); };
|
||||||
|
|
||||||
// Exponent
|
// Exponent
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
Reference in New Issue
Block a user