|
Boost : |
Subject: Re: [boost] [units] Interest in UDLs (e.g. _kg) for units?
From: Erik Erlandson (eje_at_[hidden])
Date: 2014-08-28 08:44:43
It might be nice to support non-abbreviated varations:
_milligram, _kiloton, _megabyte, etc.
As an aside, there is a "derived" unit for just grams defined in there somewhere, maybe as part of the CGS subsystem?
----- Original Message -----
> 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
> 5.34_g;
> 1234_kg;
>
> 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, ...
> 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).
>
> Regards,
>
> Marek Kurdej
> --
> Ph.D. candidate
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk