This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement N3642 - User-defined Literals for Standard Library Types


On 05/31/2013 10:41 AM, Daniel Krügler wrote:
2013/5/31 Ed Smith-Rowland <3dw4rd@verizon.net>:
Greetings,

This patch implements N3642 - User-defined literals for
std::chrono::duration and std::basic_string
and N3660 - User-defined literals for std::complex.
  N3660 was rejected during the Bristol meeting, the main reason being
the ugliness of the complex-float literal and giving it some time to
find a possible sore language solution. Is there still the idea to add
this now?

- Daniel

I would offer a modification of the lower-case rule for standard literal operators (I know this is bikeshed but I think such things are important and obviously prevent ideas from being adopted).

I would say:

1. Put the precision first in upper case. As a matter of style I prefer 123456L to 123456l for normal literals anyway. Also, the precision snuggles next to the number - then you modify it. That seems logical to me. Also, if we involve <decimal> in this someday, those literals *have* to be all caps (for the old literals). It seems using lower case precision indicators for decimal would be inconsistent.

  2. Use lower case for the other characters except...

3. If the name derives from a proper name, such as SI unit Farad use capitals. This will make literal operators for units match SI and the expectation of users most likely to use such literals.

For complex this gives us:

  std::complex<float>
operator"" Fi(long double imag) noexcept;

  std::complex<float>
operator"" Fi(unsigned long long imag) noexcept;

std::complex<double>
operator"" i(long double imag) noexcept;

std::complex<double>
operator"" i(unsigned long long imag) noexcept;

std::complex<long double>
operator"" Li(long double imag) noexcept;

std::complex<long double>
operator"" Li(unsigned long long imag) noexcept;

This avoids the i_f, and seems more logical to me.

For the issue at hand, I split the patch.

Ed

Attachment: patch_okliterals
Description: Text document

Attachment: CL_cmplxliterals
Description: Text document

Attachment: CL_okliterals
Description: Text document

Attachment: patch_cmplxliterals
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]