fix: Visual Studio caught up with terse form of constraints

This commit is contained in:
Mateusz Pusz
2021-03-12 23:06:11 +01:00
parent a91e234c90
commit 069712b222
5 changed files with 15 additions and 19 deletions

View File

@ -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()

View File

@ -69,12 +69,12 @@ inline namespace literals {
constexpr auto operator"" _N(unsigned long long v) { return latitude(static_cast<latitude::value_type>(v)); }
constexpr auto operator"" _N(long double v) { return latitude(static_cast<latitude::value_type>(v)); }
constexpr auto operator"" _S(unsigned long long v) { return latitude(static_cast<latitude::value_type>(-v)); }
constexpr auto operator"" _S(long double v) { return latitude(static_cast<latitude::value_type>(-v)); }
constexpr auto operator"" _S(unsigned long long v) { return latitude(-static_cast<latitude::value_type>(v)); }
constexpr auto operator"" _S(long double v) { return latitude(-static_cast<latitude::value_type>(v)); }
constexpr auto operator"" _E(unsigned long long v) { return longitude(static_cast<longitude::value_type>(v)); }
constexpr auto operator"" _E(long double v) { return longitude(static_cast<longitude::value_type>(v)); }
constexpr auto operator"" _W(unsigned long long v) { return longitude(static_cast<longitude::value_type>(-v)); }
constexpr auto operator"" _W(long double v) { return longitude(static_cast<longitude::value_type>(-v)); }
constexpr auto operator"" _W(unsigned long long v) { return longitude(-static_cast<longitude::value_type>(v)); }
constexpr auto operator"" _W(long double v) { return longitude(-static_cast<longitude::value_type>(v)); }
} // namespace literals

View File

@ -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);

View File

@ -107,8 +107,6 @@ struct fmt::formatter<glide_computer::altitude> : formatter<units::physical::si:
// definition of glide computer databases and utilities
namespace glide_computer {
using namespace si::unit_constants;
struct glider {
struct polar_point {
velocity v;
@ -162,7 +160,7 @@ public:
distance get_length() const { return length_; }
distance get_leg_dist_offset(size_t leg_index) const { return leg_index == 0 ? distance(0 * km) : leg_total_distances_[leg_index - 1]; }
distance get_leg_dist_offset(size_t leg_index) const { return leg_index == 0 ? distance{} : leg_total_distances_[leg_index - 1]; }
size_t get_leg_index(distance dist) const
{
return static_cast<size_t>(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);

View File

@ -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";
}