From 069712b2223d4c2888a2bdd323dea18426d09e96 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 12 Mar 2021 23:06:11 +0100 Subject: [PATCH] fix: :sparkles: Visual Studio caught up with terse form of constraints --- example/CMakeLists.txt | 6 ------ example/geographic.h | 8 ++++---- example/glide_computer.cpp | 2 +- example/glide_computer.h | 6 ++---- example/glide_computer_example.cpp | 12 ++++++++---- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ee60be3b..a8f130f6 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -39,10 +39,6 @@ add_example(kalman_filter-alpha_beta_filter_example2) add_example(measurement) add_example(unknown_dimension) -if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - -# TODO Those examples use Concepts terse syntax not yet supported by MSVC - add_example(avg_speed) add_example(hello_units) add_example(total_energy) @@ -64,5 +60,3 @@ target_link_libraries(linear_algebra ) add_subdirectory(alternative_namespaces) - -endif() diff --git a/example/geographic.h b/example/geographic.h index b03eab3b..d2fb46d4 100644 --- a/example/geographic.h +++ b/example/geographic.h @@ -69,12 +69,12 @@ inline namespace literals { constexpr auto operator"" _N(unsigned long long v) { return latitude(static_cast(v)); } constexpr auto operator"" _N(long double v) { return latitude(static_cast(v)); } -constexpr auto operator"" _S(unsigned long long v) { return latitude(static_cast(-v)); } -constexpr auto operator"" _S(long double v) { return latitude(static_cast(-v)); } +constexpr auto operator"" _S(unsigned long long v) { return latitude(-static_cast(v)); } +constexpr auto operator"" _S(long double v) { return latitude(-static_cast(v)); } constexpr auto operator"" _E(unsigned long long v) { return longitude(static_cast(v)); } constexpr auto operator"" _E(long double v) { return longitude(static_cast(v)); } -constexpr auto operator"" _W(unsigned long long v) { return longitude(static_cast(-v)); } -constexpr auto operator"" _W(long double v) { return longitude(static_cast(-v)); } +constexpr auto operator"" _W(unsigned long long v) { return longitude(-static_cast(v)); } +constexpr auto operator"" _W(long double v) { return longitude(-static_cast(v)); } } // namespace literals diff --git a/example/glide_computer.cpp b/example/glide_computer.cpp index f875e413..4746c4f4 100644 --- a/example/glide_computer.cpp +++ b/example/glide_computer.cpp @@ -153,7 +153,7 @@ void estimate(timestamp start_ts, const glider& g, const weather& w, const task& // circle in a thermall to gain height pos = circle(start_ts, pos, g, w, t, height_to_gain); - } while (height_to_gain > height(0 * m)); + } while (height_to_gain > height{}); // final glide pos = final_glide(start_ts, pos, g, t); diff --git a/example/glide_computer.h b/example/glide_computer.h index 8c191497..4d4cac5f 100644 --- a/example/glide_computer.h +++ b/example/glide_computer.h @@ -107,8 +107,6 @@ struct fmt::formatter : formatter(std::ranges::distance(leg_total_distances_.cbegin(), std::ranges::lower_bound(leg_total_distances_, dist))); @@ -191,7 +189,7 @@ struct flight_point { timestamp ts; altitude alt; size_t leg_idx = 0; - distance dist{0 * km}; + distance dist{}; }; altitude terrain_level_alt(const task& t, const flight_point& pos); diff --git a/example/glide_computer_example.cpp b/example/glide_computer_example.cpp index 8b7414e4..b770c58c 100644 --- a/example/glide_computer_example.cpp +++ b/example/glide_computer_example.cpp @@ -31,6 +31,7 @@ using namespace glide_computer; auto get_gliders() { + using namespace si::unit_constants; static const std::array gliders = { glider{"SZD-30 Pirat", {velocity(83 * km / h), rate_of_climb(-0.7389 * m / s)}}, glider{"SZD-51 Junior", {velocity(80 * km / h), rate_of_climb(-0.6349 * m / s)}}, @@ -41,6 +42,7 @@ auto get_gliders() auto get_weather_conditions() { + using namespace si::unit_constants; static const std::array weather_conditions = { std::pair("Good", weather{height(1900 * m), rate_of_climb(4.3 * m / s)}), std::pair("Medium", weather{height(1550 * m), rate_of_climb(2.8 * m / s)}), @@ -135,17 +137,19 @@ void print(const aircraft_tow& tow) void example() { - const safety s = {height(300 * m)}; + using namespace si::unit_constants; + + const safety sfty = {height(300 * m)}; const auto gliders = get_gliders(); const auto waypoints = get_waypoints(); const auto weather_conditions = get_weather_conditions(); const task t = {waypoints[0], waypoints[1], waypoints[0]}; - const aircraft_tow tow = {height(400 * m), rate_of_climb(1.6 * m / ::s)}; + const aircraft_tow tow = {height(400 * m), rate_of_climb(1.6 * m / s)}; // TODO use C++20 date library when available // set `start_time` to 11:00 am today const timestamp start_time(std::chrono::system_clock::now()); - print(s); + print(sfty); print(gliders); print(waypoints); print(weather_conditions); @@ -158,7 +162,7 @@ void example() std::cout << txt << "\n"; fmt::print("{0:=^{1}}\n\n", "", txt.size()); - estimate(start_time, g, c.second, t, s, tow); + estimate(start_time, g, c.second, t, sfty, tow); std::cout << "\n\n"; }