From ed15ef772984cae2582edb26f83cf92171c16dbb Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 7 Sep 2020 13:17:06 +0200 Subject: [PATCH 1/9] docs: unintended links replaced with code snippets (I have this part of RST) --- docs/faq.rst | 8 ++++---- docs/usage.rst | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 5b1e8d64..8e011f4f 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -51,8 +51,8 @@ naming and we came up with ``q_`` prefix which results in a creation of 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 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 to make it work: -- `/wd4455` on MSVC, -- `-Wno-literal-suffix` on other compilers. +- ``/wd4455`` on MSVC, +- ``-Wno-literal-suffix`` on other compilers. Text formatting diff --git a/docs/usage.rst b/docs/usage.rst index 918a49c7..4184790a 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -263,7 +263,7 @@ differences: `the project's README file `_ or on `the project's Bintray `_. -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 @@ -281,7 +281,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 follows: -1. Specify `cmake` generator in your Conan configuration file: +1. Specify ``cmake`` generator in your Conan configuration file: .. code-block:: ini :caption: conanfile.txt @@ -319,7 +319,7 @@ in **mp-units** repository, you should: 1. Add remotes of additional Conan dependencies. 2. Use the *CMakeLists.txt* from the top-level directory. 3. Obtain Python dependencies. -4. Run Conan with :envvar:`CONAN_RUN_TESTS` = ``True``. +4. Run Conan with `CONAN_RUN_TESTS`_ = ``True``. .. code-block:: shell From 0e6142a5d21f4ba814f51a05ff3b49fb06efface Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 7 Sep 2020 15:06:01 +0200 Subject: [PATCH 2/9] docs: missing build dependencies added --- docs/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index c595a723..5b784d58 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -95,6 +95,7 @@ add_custom_command(OUTPUT "${SPHINX_INDEX_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/examples/linear_algebra.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/measurement.rst" "${CMAKE_CURRENT_SOURCE_DIR}/examples/total_energy.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/examples/unknown_dimension.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/dimensions.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/units.rst" From db041061e095e33c6c8f6d870d02c23e9765b8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 00:43:42 -0400 Subject: [PATCH 3/9] chore: iwyu --- src/include/units/bits/external/type_traits.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/units/bits/external/type_traits.h b/src/include/units/bits/external/type_traits.h index f48bd2ce..91a3fab2 100644 --- a/src/include/units/bits/external/type_traits.h +++ b/src/include/units/bits/external/type_traits.h @@ -24,6 +24,7 @@ #include #include +#include namespace units { From e30aa9c4a00f6a1bd8a2ff46a78d738ca77ec04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 00:57:05 -0400 Subject: [PATCH 4/9] refactor: simplify is_specialization_of --- src/include/units/bits/external/type_traits.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/include/units/bits/external/type_traits.h b/src/include/units/bits/external/type_traits.h index 91a3fab2..226be77b 100644 --- a/src/include/units/bits/external/type_traits.h +++ b/src/include/units/bits/external/type_traits.h @@ -59,18 +59,11 @@ template using is_same = std::bool_constant>; // is_specialization_of -namespace detail { - template typename Type> -inline constexpr bool is_specialization_of_impl = false; +inline constexpr bool is_specialization_of = false; template typename Type> -inline constexpr bool is_specialization_of_impl, Type> = true; - -} // namespace detail - -template typename Type> -inline constexpr bool is_specialization_of = detail::is_specialization_of_impl; +inline constexpr bool is_specialization_of, Type> = true; // is_derived_from_specialization_of namespace detail { From 7c00b196a3056c353bc5b3e3d000bf2d9ef50484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 01:14:14 -0400 Subject: [PATCH 5/9] refactor: simplify is_derived_from_specialization_of --- src/include/units/bits/external/type_traits.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/include/units/bits/external/type_traits.h b/src/include/units/bits/external/type_traits.h index 226be77b..34b4ddda 100644 --- a/src/include/units/bits/external/type_traits.h +++ b/src/include/units/bits/external/type_traits.h @@ -68,16 +68,12 @@ inline constexpr bool is_specialization_of, Type> = true; // is_derived_from_specialization_of namespace detail { -template typename Type> -struct is_derived_from_specialization_of_impl { - template - static constexpr std::true_type check_base(const Type&); - static constexpr std::false_type check_base(...); -}; +template typename Type, typename... Params> +void to_base_specialization_of(const volatile Type*); } // namespace detail template typename Type> -inline constexpr bool is_derived_from_specialization_of = decltype(detail::is_derived_from_specialization_of_impl::check_base(std::declval()))::value; +concept is_derived_from_specialization_of = requires { detail::to_base_specialization_of(std::declval()); }; } // namespace units From 929913117419ed6edf3a50cab1ef79db1bf051e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 01:53:19 -0400 Subject: [PATCH 6/9] refactor: simplify is_derived_from_{scaled_unit,base_dimension} --- src/include/units/concepts.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 549c8742..a60a852c 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -80,14 +80,11 @@ struct scaled_unit; // TODO: Remove when P1985 accepted namespace detail { -struct is_derived_from_scaled_unit_impl { - template - static constexpr std::true_type check_base(const scaled_unit&); - static constexpr std::false_type check_base(...); -}; +template +void to_base_scaled_unit(const volatile scaled_unit*); template -inline constexpr bool is_derived_from_scaled_unit = decltype(is_derived_from_scaled_unit_impl::check_base(std::declval()))::value; +concept is_derived_from_scaled_unit = requires { to_base_scaled_unit(std::declval()); }; } // namespace detail @@ -99,20 +96,18 @@ inline constexpr bool is_derived_from_scaled_unit = decltype(is_derived_from_sca template concept Unit = detail::is_derived_from_scaled_unit; +// BaseDimension template requires U::is_named struct base_dimension; namespace detail { -struct is_derived_from_base_dimension_impl { - template - static constexpr std::true_type check_base(const base_dimension&); - static constexpr std::false_type check_base(...); -}; +template +void to_base_base_dimension(const volatile base_dimension*); template -inline constexpr bool is_derived_from_base_dimension = decltype(is_derived_from_base_dimension_impl::check_base(std::declval()))::value; +concept is_derived_from_base_dimension = requires { to_base_base_dimension(std::declval()); }; } // namespace detail From fac1f582c8169d0cf6995b6dfe77b1d7bdfcb847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 02:04:02 -0400 Subject: [PATCH 7/9] chore: iwyu --- src/include/units/concepts.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index a60a852c..27ec3a0b 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace units { From 8fc0c254a64ff9ce766107b3ddaed8541ebf5b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 18:33:19 -0400 Subject: [PATCH 8/9] style: add TODO comment for when to update --- src/include/units/bits/external/type_traits.h | 1 + src/include/units/concepts.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/include/units/bits/external/type_traits.h b/src/include/units/bits/external/type_traits.h index 34b4ddda..db607b05 100644 --- a/src/include/units/bits/external/type_traits.h +++ b/src/include/units/bits/external/type_traits.h @@ -74,6 +74,7 @@ void to_base_specialization_of(const volatile Type*); } // namespace detail template typename Type> +// inline constexpr bool // TODO: Replace with concept when it works with MSVC concept is_derived_from_specialization_of = requires { detail::to_base_specialization_of(std::declval()); }; } // namespace units diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 27ec3a0b..b165faec 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -86,6 +86,7 @@ template void to_base_scaled_unit(const volatile scaled_unit*); template +// inline constexpr bool // TODO: Replace with concept when it works with MSVC concept is_derived_from_scaled_unit = requires { to_base_scaled_unit(std::declval()); }; } // namespace detail @@ -109,6 +110,7 @@ template void to_base_base_dimension(const volatile base_dimension*); template +// inline constexpr bool // TODO: Replace with concept when it works with MSVC concept is_derived_from_base_dimension = requires { to_base_base_dimension(std::declval()); }; } // namespace detail From f83ba6eb39bb5117a5f3aee8e60e02d16445b890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 7 Sep 2020 23:28:02 -0400 Subject: [PATCH 9/9] refactor: remove indirection for further simplification --- src/include/units/concepts.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index b165faec..45f64bea 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -85,10 +85,6 @@ namespace detail { template void to_base_scaled_unit(const volatile scaled_unit*); -template -// inline constexpr bool // TODO: Replace with concept when it works with MSVC -concept is_derived_from_scaled_unit = requires { to_base_scaled_unit(std::declval()); }; - } // namespace detail /** @@ -97,7 +93,7 @@ concept is_derived_from_scaled_unit = requires { to_base_scaled_unit(std::declva * Satisfied by all unit types derived from an specialization of :class:`scaled_unit`. */ template -concept Unit = detail::is_derived_from_scaled_unit; +concept Unit = requires { detail::to_base_scaled_unit(std::declval()); }; // BaseDimension template @@ -109,10 +105,6 @@ namespace detail { template void to_base_base_dimension(const volatile base_dimension*); -template -// inline constexpr bool // TODO: Replace with concept when it works with MSVC -concept is_derived_from_base_dimension = requires { to_base_base_dimension(std::declval()); }; - } // namespace detail /** @@ -121,7 +113,7 @@ concept is_derived_from_base_dimension = requires { to_base_base_dimension(std:: * Satisfied by all dimension types derived from an specialization of `base_dimension`. */ template -concept BaseDimension = detail::is_derived_from_base_dimension; +concept BaseDimension = requires { detail::to_base_base_dimension(std::declval()); }; // Exponent namespace detail {