From b78b53e75727b5cba70543caef2371c57395af8d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 4 Jan 2023 15:32:13 +0100 Subject: [PATCH] build(example): `custom_systems` example removed as not relevant anymore --- example/CMakeLists.txt | 43 +++++++++----- example/custom_systems.cpp | 117 ------------------------------------- 2 files changed, 29 insertions(+), 131 deletions(-) delete mode 100644 example/custom_systems.cpp diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index c04c32c0..7ff834cf 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -33,19 +33,34 @@ function(add_example target) target_link_libraries(${target} PRIVATE ${ARGN}) endfunction() -add_example(v2_framework mp-units::core mp-units::si) +add_example(avg_speed mp-units::core-io mp-units::si mp-units::cgs mp-units::usc) +add_example(box_example mp-units::core-fmt mp-units::si) +add_example(capacitor_time_curve mp-units::core-io mp-units::si mp-units::utility) +add_example( + clcpp_response + mp-units::core-fmt + mp-units::core-io + mp-units::si + mp-units::iau + mp-units::imperial + mp-units::international + mp-units::typographic + mp-units::usc +) +add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si) +add_example(foot_pound_second mp-units::core-fmt mp-units::international mp-units::imperial) +add_example(glide_computer_example mp-units::core-fmt mp-units::international mp-units::utility glide_computer) +add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::usc) +add_example(measurement mp-units::core-io mp-units::si) +add_example(si_constants mp-units::core-fmt mp-units::si) +add_example( + strong_angular_quantities mp-units::core-fmt mp-units::core-io mp-units::si mp-units::isq_angle mp-units::utility +) +add_example(total_energy mp-units::core-io mp-units::si mp-units::natural mp-units::utility) -# add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si) -# add_example(custom_systems mp-units::core-io mp-units::si) -# add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-international) -# add_example(measurement mp-units::core-io mp-units::si) -# add_example(si_constants mp-units::core-fmt mp-units::si) +find_package(wg21_linear_algebra CONFIG REQUIRED) +add_example(linear_algebra mp-units::core-fmt mp-units::core-io mp-units::si) +target_link_libraries(linear_algebra PRIVATE wg21_linear_algebra::wg21_linear_algebra) -# if(NOT ${projectPrefix}LIBCXX) -# add_subdirectory(glide_computer) -# endif() - -# add_subdirectory(aliases) -# add_subdirectory(kalman_filter) -# add_subdirectory(literals) -# add_subdirectory(references) +add_subdirectory(glide_computer) +add_subdirectory(kalman_filter) diff --git a/example/custom_systems.cpp b/example/custom_systems.cpp deleted file mode 100644 index c708bf0f..00000000 --- a/example/custom_systems.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include -#include -#include -#include -#include - -using namespace units; - -namespace fps { - -struct foot : named_unit {}; -struct yard : named_scaled_unit(), foot> {}; - -struct dim_length : base_dimension<"L", foot> {}; - -template U, Representation Rep = double> -using length = quantity; - -} // namespace fps - -namespace si { - -struct metre : named_unit {}; -struct kilometre : prefixed_unit {}; - -struct dim_length : base_dimension<"L", metre> {}; - -template U, Representation Rep = double> -using length = quantity; - -namespace fps { - -struct foot : named_scaled_unit(), metre> {}; -struct yard : named_scaled_unit(), foot> {}; - -struct dim_length : base_dimension<"L", foot> {}; - -template U, Representation Rep = double> -using length = quantity; - -} // namespace fps -} // namespace si - -template -concept castable_to = Quantity && Unit && requires(Q q) { quantity_cast(q); }; - -void conversions() -{ - // fps::yard is not defined in terms of SI units (or vice-versa) - // so the conversion between FPS and SI is not possible - static_assert(!castable_to, si::kilometre>); - - // si::fps::yard is defined in terms of SI units - // so the conversion between FPS and SI is possible - static_assert(castable_to, si::kilometre>); - constexpr auto si_fps_yard = si::fps::length(1.); - std::cout << quantity_cast(si_fps_yard) << "\n"; -} - -void unknown_dimensions() -{ - constexpr auto fps_yard = fps::length(1.); - constexpr auto fps_area = fps_yard * fps_yard; - std::cout << fps_yard << "\n"; - std::cout << quantity_cast(fps_area) << "\n"; - - constexpr auto si_fps_yard = si::fps::length(1.); - constexpr auto si_fps_area = si_fps_yard * si_fps_yard; - std::cout << si_fps_yard << "\n"; - std::cout << quantity_cast(si_fps_area) << "\n"; -} - -std::ostream& operator<<(std::ostream& os, const ratio& r) { return os << "ratio{" << r.num << ", " << r.den << "}"; } - -template -std::ostream& operator<<(std::ostream& os, const U& u) -{ - using unit_type = std::remove_cvref_t; - return os << as_ratio(unit_type::mag) << " x " << unit_type::reference::symbol.standard(); -} - -void what_is_your_ratio() -{ - std::cout << "fps: " << fps::yard() << "\n"; - std::cout << "si::fps: " << si::fps::yard() << "\n"; -} - -int main() -{ - conversions(); - unknown_dimensions(); - what_is_your_ratio(); -}