Subject: [boost] [units] Interest in UDLs (e.g. _kg) for units?
From: Curdeius Curdeius (curdeius_at_[hidden])
Date: 2014-08-22 04:08:34
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
BOOST_NO_CXX11_USER_DEFINED_LITERALS is not defined).
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, ...
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
-- Ph.D. candidate
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk