OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine/units.cpp

Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

#include <iostream>
template <typename Unit>
template <typename Unit>
void print(const qty<Unit>& q) {
using eagine::units::get_name;
using eagine::units::get_name_form;
using eagine::units::get_symbol;
const auto dim = get_dimension(q.unit());
std::cout << get_name(dim) << " (" << get_name_form(dim)
<< "): " << q.value() << " [" << get_symbol(q.unit()) << " ("
<< get_name_form(q.unit()) << ")]\n";
}
auto main() -> int {
using namespace eagine::units;
qty<meter> x{2.F};
qty<meter> y{3.F};
qty<meter> z{4.F};
qty<newton> f{12.F};
qty<second> t{6.F};
auto a = x * y;
auto v = a * z;
auto s = f / a;
auto e = v * s;
auto p = e / t;
print(x);
print(y);
print(a);
print(v);
print(t);
print(f);
print(s);
print(e);
print(p);
return 0;
}
static constexpr auto unit() noexcept -> U
Returns the unit.
Definition: tagged_quantity.hpp:74
constexpr auto value() const noexcept -> T
Returns the value.
Definition: tagged_quantity.hpp:69
Value of type T with a specified unit or tag type U.
Definition: tagged_quantity.hpp:27

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).