xo-unit: ex1: upgrade to qty::quantity<..> with constexpr units
This commit is contained in:
parent
2f9266b6ed
commit
8f7d60dd21
2 changed files with 16 additions and 8 deletions
|
|
@ -10,6 +10,7 @@ xo_include_options2(${SELF_EXE})
|
|||
# dependencies..
|
||||
|
||||
xo_self_headeronly_dependency(${SELF_EXE} xo_unit)
|
||||
xo_dependency(${SELF_EXE} xo_flatstring)
|
||||
#xo_dependency(${SELF_EXE} reflect)
|
||||
|
||||
# end CMakeLists.txt
|
||||
|
|
|
|||
|
|
@ -1,22 +1,29 @@
|
|||
/** @file ex1.cpp **/
|
||||
|
||||
#include "xo/unit/mpl/quantity.hpp"
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include "xo/unit/quantity_iostream.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace u = xo::unit::units;
|
||||
namespace qty = xo::unit::qty;
|
||||
using xo::unit::quantity;
|
||||
namespace q = xo::qty::qty;
|
||||
using xo::qty::quantity;
|
||||
using namespace std;
|
||||
|
||||
auto t = qty::milliseconds(10);
|
||||
auto m = qty::kilograms(2.5);
|
||||
auto a = m / (t*t);
|
||||
constexpr auto t = q::milliseconds(10);
|
||||
constexpr auto m = q::kilograms(2.5);
|
||||
|
||||
constexpr auto t2 = t*t;
|
||||
#ifdef NOT_YET
|
||||
constexpr auto a = m / (t*t);
|
||||
|
||||
static_assert(same_as<decltype(t), quantity<u::millisecond, int>>);
|
||||
#endif
|
||||
|
||||
cerr << "t: " << t << ", m: " << m << ", m.t^-2: " << a << endl;
|
||||
cerr << "t: " << t << ", m: " << m
|
||||
<< ", t^2: " << t2
|
||||
//<< ", m.t^-2: " << a
|
||||
<< endl;
|
||||
}
|
||||
|
||||
/** end ex1.cpp **/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue