xo-unit: kitchen-sink doc + build improvements + 1 bug fix

This commit is contained in:
Roland Conybeare 2024-05-22 15:16:17 -04:00
commit 412a0ba163
45 changed files with 1712 additions and 472 deletions

View file

@ -0,0 +1,12 @@
# xo-unit/example/ex8/CMakeLists.txt
set(SELF_EXE xo_unit_ex8)
set(SELF_SRCS ex8.cpp)
if (XO_ENABLE_EXAMPLES)
xo_add_executable(${SELF_EXE} ${SELF_SRCS})
xo_self_headeronly_dependency(${SELF_EXE} xo_unit)
xo_dependency(${SELF_EXE} xo_flatstring)
endif()
# end CMakeLists.txt

29
example/ex8/ex8.cpp Normal file
View file

@ -0,0 +1,29 @@
/** @file ex8.cpp **/
#include "xo/unit/xquantity.hpp"
#include "xo/unit/xquantity_iostream.hpp"
#include <iostream>
int
main () {
using namespace xo::qty;
namespace u = xo::qty::u;
//namespace q = xo::qty::qty;
using namespace std;
xquantity qty1(7, u::foot);
xquantity qty2(6.0, u::inch);
xquantity qty3 = qty1 + qty2;
cerr << "qty1: " << qty1 << endl;
cerr << "qty2: " << qty2 << endl;
cerr << "qty3: " << qty3 << endl;
/* rescale to mm */
xquantity res = qty3.rescale(xo::qty::nu::millimeter);
/* 2286mm */
cerr << "res: " << res << endl;
}
/** end ex8.cpp */