git subrepo clone git@github.com:Rconybea/xo-unit.git xo-unit
subrepo: subdir: "xo-unit" merged: "f1e698bf" upstream: origin: "git@github.com:Rconybea/xo-unit.git" branch: "main" commit: "f1e698bf" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
This commit is contained in:
parent
b135d1813b
commit
60f796b770
106 changed files with 11919 additions and 0 deletions
30
xo-unit/example/ex4/ex4.cpp
Normal file
30
xo-unit/example/ex4/ex4.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/** @file ex4.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include "xo/unit/quantity_iostream.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace q = xo::qty::qty;
|
||||
|
||||
auto t1 = q::milliseconds(1);
|
||||
auto t2 = q::minutes(1);
|
||||
|
||||
auto r1 = t1 / with_repr<double>(t2);
|
||||
|
||||
static_assert(r1.is_dimensionless());
|
||||
static_assert(!t2.is_dimensionless());
|
||||
|
||||
static_assert(std::same_as<decltype(static_cast<double>(r1)), double>);
|
||||
|
||||
/* r1_value: assignment compiles, since r1 dimensionless */
|
||||
double r1_value = r1;
|
||||
|
||||
/* r2_value: assignment won't compile, 'cannot convert' error */
|
||||
//double r2_value = t2;
|
||||
|
||||
std::cerr << "t1: " << t1 << ", t2: " << t2 << ", t1/t2: " << r1 << std::endl;
|
||||
}
|
||||
|
||||
/** end ex4.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue