mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
refactor: public headers cleanup
Public headers should be only the ones that a user may have a need to actually include in his/her code.
This commit is contained in:
@@ -38,26 +38,17 @@ add_library(
|
||||
mp-units-core
|
||||
INTERFACE
|
||||
# include/units/chrono.h
|
||||
include/units/concepts.h
|
||||
include/units/customization_points.h
|
||||
include/units/dimension.h
|
||||
# include/units/generic/angle.h
|
||||
include/units/generic/dimensionless.h
|
||||
# include/units/generic/solid_angle.h
|
||||
# include/units/kind.h
|
||||
include/units/magnitude.h
|
||||
include/units/math.h
|
||||
# include/units/point_origin.h
|
||||
include/units/quantity.h
|
||||
include/units/quantity_cast.h
|
||||
# include/units/quantity_kind.h
|
||||
# include/units/quantity_point.h
|
||||
# include/units/quantity_point_kind.h
|
||||
include/units/quantity_spec.h
|
||||
include/units/random.h
|
||||
include/units/ratio.h
|
||||
include/units/reference.h
|
||||
include/units/symbol_text.h
|
||||
include/units/system_reference.h
|
||||
include/units/unit.h
|
||||
)
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/bits/external/type_list.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/ratio.h>
|
||||
#include <units/bits/ratio.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
|
@@ -24,14 +24,14 @@
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/external/text_tools.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/prime.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/ratio.h>
|
||||
#include <units/symbol_text.h>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
@@ -23,10 +23,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/concepts.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/magnitude.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/unit.h>
|
||||
@@ -50,16 +51,6 @@ inline constexpr bool is_specialization_of_reference<reference<Q, U>> = true;
|
||||
template<typename T>
|
||||
concept Reference = detail::is_specialization_of_reference<T>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool is_quantity = false;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
concept Quantity = detail::is_quantity<T>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept common_type_with_ = // exposition only
|
||||
(std::same_as<std::common_type_t<T, U>, std::common_type_t<U, T>>) &&
|
||||
@@ -80,25 +71,33 @@ concept scalable_ = // exposition only
|
||||
scalable_number_<T, std::common_type_t<typename T::value_type, std::intmax_t>>);
|
||||
|
||||
template<typename T>
|
||||
concept Representation = (!Quantity<T>) &&
|
||||
// (!QuantityLike<T>) && (!wrapped_quantity_<T>) &&
|
||||
std::regular<T> && scalable_<T>;
|
||||
concept Representation = (is_scalar<T> || is_vector<T> || is_tensor<T>) && std::regular<T> && scalable_<T>;
|
||||
|
||||
template<Reference auto R, Representation Rep>
|
||||
template<typename T, quantity_character Ch>
|
||||
concept RepresentationOf = Representation<T> && ((Ch == quantity_character::scalar && is_scalar<T>) ||
|
||||
(Ch == quantity_character::vector && is_vector<T>) ||
|
||||
(Ch == quantity_character::tensor && is_tensor<T>));
|
||||
|
||||
template<Reference auto R, RepresentationOf<R.quantity_spec.character> Rep>
|
||||
class quantity;
|
||||
|
||||
namespace detail {
|
||||
|
||||
// TODO make the below code from the comment to compile and replace it
|
||||
template<auto R, typename Rep>
|
||||
inline constexpr bool is_quantity<quantity<R, Rep>> = true;
|
||||
void to_base_specialization_of_quantity(const volatile quantity<R, Rep>*);
|
||||
|
||||
// template<auto R, typename Rep>
|
||||
// void to_base_specialization_of_quantity(const volatile quantity<R, Rep>*);
|
||||
} // namespace detail
|
||||
|
||||
// template<typename T>
|
||||
// requires requires(T* t) { to_base_specialization_of_quantity(t); }
|
||||
// inline constexpr bool is_quantity<T> = true;
|
||||
template<typename T>
|
||||
concept Quantity = requires(T* t) { detail::to_base_specialization_of_quantity(t); };
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<QuantitySpec Q1, QuantitySpec Q2>
|
||||
[[nodiscard]] consteval bool is_kind_of(Q1, Q2)
|
||||
{
|
||||
return std::derived_from<Q1, Q2>;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -109,9 +108,10 @@ inline constexpr bool is_quantity<quantity<R, Rep>> = true;
|
||||
* the provided dimension/reference type.
|
||||
*/
|
||||
template<typename Q, auto V>
|
||||
concept quantity_of = Quantity<Q> && ((Dimension<std::remove_const_t<decltype(V)>> && Q::dimension == V) ||
|
||||
(QuantitySpec<std::remove_const_t<decltype(V)>> && Q::quantity_spec == V) ||
|
||||
(Reference<std::remove_const_t<decltype(V)>> && Q::reference == V));
|
||||
concept quantity_of = Quantity<Q> &&
|
||||
((Dimension<std::remove_const_t<decltype(V)>> && Q::dimension == V) ||
|
||||
(QuantitySpec<std::remove_const_t<decltype(V)>> && detail::is_kind_of(Q::quantity_spec, V)) ||
|
||||
(Reference<std::remove_const_t<decltype(V)>> && Q::reference == V));
|
||||
|
||||
/**
|
||||
* @brief A concept matching all quantities with provided dimension or reference
|
@@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/symbol_text.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
|
||||
namespace units::detail {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/symbol_text.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
|
@@ -23,10 +23,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/quantity_cast.h>
|
||||
// #include <units/ratio.h>
|
||||
#include <units/concepts.h>
|
||||
#include <units/bits/quantity_cast.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/concepts.h>
|
||||
#include <units/quantity.h>
|
||||
#include <functional>
|
||||
#include <random>
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/concepts.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/concepts.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
|
@@ -25,13 +25,13 @@
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/external/text_tools.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/magnitude.h>
|
||||
#include <units/ratio.h>
|
||||
#include <units/symbol_text.h>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
|
@@ -20,8 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/magnitude.h>
|
||||
#include <units/ratio.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace units;
|
||||
|
@@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/ratio.h>
|
||||
#include <units/bits/ratio.h>
|
||||
|
||||
namespace {
|
||||
|
||||
|
Reference in New Issue
Block a user