Boost logo

Boost :

Subject: [boost] [units] Interest in UDLs (e.g. _kg) for units?
From: Curdeius Curdeius (curdeius_at_[hidden])
Date: 2014-08-22 04:08:34

Hi all,

I was wondering if there is any interest in adding User-Defined Literals
(UDLs) to Boost.Units.

IMO, it could simplify some code and improve code readability in some cases.
For example instead of writing (it's a somehow artificial example)
    5.34 * si::milli * si::kilogram;
    1234 * si::kilogram;
one would write

I propose to add this feature for compatible compilers (where
The user would have to pull corresponding namespace (let's call it `udl`)
to use it, for example
    using namespace boost::units::systems::si::udl; // bring _kg, _km, ...
into scope

What are your feelings about it?

In the first place, I would go for `operator ""` taking as arguments `unsigned
long long` and `long double`.
Later, one could think about the one taking a `const char *` argument which
would provide a quantity with an underlying type of arbitrary precision
(like boost::multiprecision::cpp_int).


Marek Kurdej

Ph.D. candidate

Boost list run by bdawes at, gregod at, cpdaniel at, john at