Boost logo

Boost :

Subject: Re: [boost] [config/multiprecision/units/general] Do we have a policy for user-defined-literals?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-04-27 10:06:19


AMDG

On 04/27/2013 05:29 AM, John Maddock wrote:
>
> 1) We have no config macro for this new feature (I've only tested with
> GCC, and suspect Clang is the only other compiler with support at
> present). What should it be called? Would everyone be happy with
> BOOST_NO_CXX11_USER_DEFINED_LITERALS ?

Yes.

> 2) How should libraries handle these user defined suffixes? The
> essencial problem is that they have to be in current scope at point of
> use, you can never explicitly qualify them. So I suggest we use:
>
> namespace boost{ namespace mylib{ namespace literals{
>
> mytype operator "" _mysuffix(args...);
>
> }}}
>
> <snip>
>

We need a nested namespace. I think using a convention
of calling it literals:: is fine.

> 3) How should the suffixes be named? There is an obvious possibility
> for clashes here - for example the units lib would probably want to use
> _s for seconds, but no doubt other users might use it for strings and
> such like. We could insist that all such names added to a boost lib are
> suitably mangled, so "_bu_s" for boost.units.seconds, but I'm not
> convinced by that. Seems to make the feature much less useful?
>

I think we should just use the obvious short names,
and rely on users not to bring conflicting suffixes
into scope. If there's a conflict they can always
fall back on normal constructors.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk