The val.h header defines the user-defined literal _val and an equivalent
val(x) function. The returned object can (and must) be converted to any
arithmetic type. If the value changes on conversion,
vir::bad_value_preserving_cast is thrown. All of this happens at compile time
(consteval).
#include <vir/val.h>
using vir::operator""_val;
auto displace(std::floating_point auto x)
{
return x + 0x5EAF00D_val;
}
double a = displace(1.); // OK
float b = displace(1.f); // ill-formedThe displace<float> call fails because int(float(0x5EAF00D)) != 0x5EAF00D.
cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake --build build --target installAlternatively, a Makefile is provided which allows installation via
make install prefix=$HOME/.local