xo-unit: ex3 using up-to-date compile-time units
This commit is contained in:
parent
42503feb62
commit
76043fb7cb
2 changed files with 17 additions and 7 deletions
|
|
@ -10,6 +10,6 @@ xo_include_options2(${SELF_EXE})
|
||||||
# dependencies..
|
# dependencies..
|
||||||
|
|
||||||
xo_self_headeronly_dependency(${SELF_EXE} xo_unit)
|
xo_self_headeronly_dependency(${SELF_EXE} xo_unit)
|
||||||
#xo_dependency(${SELF_EXE} reflect)
|
xo_dependency(${SELF_EXE} xo_flatstring)
|
||||||
|
|
||||||
# end CMakeLists.txt
|
# end CMakeLists.txt
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,28 @@
|
||||||
/** @file ex3.cpp **/
|
/** @file ex3.cpp **/
|
||||||
|
|
||||||
#include "xo/unit/mpl/quantity.hpp"
|
#include "xo/unit/quantity.hpp"
|
||||||
|
#include "xo/unit/quantity_iostream.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int
|
int
|
||||||
main () {
|
main () {
|
||||||
namespace u = xo::unit::units;
|
namespace q = xo::qty::qty;
|
||||||
namespace qty = xo::unit::qty;
|
namespace u = xo::qty::nu;
|
||||||
|
using xo::qty::with_units;
|
||||||
|
using xo::qty::stdquantity;
|
||||||
|
using xo::qty::quantity;
|
||||||
|
using xo::flatstring;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
auto t1 = qty::milliseconds(1);
|
constexpr stdquantity<u::second> t = q::minutes(2);
|
||||||
auto t2 = qty::minutes(1);
|
constexpr stdquantity<u::meter> d = q::kilometers(2.5);
|
||||||
|
|
||||||
cerr << "t1: " << t1 << ", t2: " << t2 << ", t1*t2: " << t1*t2 << endl;
|
constexpr auto t2 = t*t;
|
||||||
|
constexpr auto a = d / (t*t);
|
||||||
|
|
||||||
|
cerr << "t: " << t << ", d: " << d
|
||||||
|
<< ", d.t^-2: " << a
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** end ex3.cpp **/
|
/** end ex3.cpp **/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue