Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2021-01-07 14:50:26


> (I'm sorry to hijack a little bit)
You can send a new mail with a new topic
> I am planning to implement units in YADE [1][2], and initially I wanted to use _m
> _km _s names, so that I could write: 1.0_km instead of 1.0km
>
> Then I decided against it, because of UB.
> Then I saw in boost ublas tensor this example:
>
> Which is using exactly the notation which I need: 10_kPa is easier to
> read than 10kPa, or 10_Pa vs 10Pa
>
> So. Where exactly do we have UB ?
> Would simply putting it into separate namespace yade::units solve the problem?
>
> Are there only certain letters forbidden after a starting underscore?
All names beginning with double-underscore or underscore+capital are
forbidden.

https://en.cppreference.com/w/cpp/language/user_literal shows that `_Z`
is fine:

double operator"" _Z(long double); // error: all names that begin with underscore
                                    // followed by uppercase letter are reserved
double operator""_Z(long double); // OK: even though _Z is reserved ""_Z is allowed

So yes _Pa is fine as long as you write your UDL in the 2nd version




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