Title
codecvt_mode should be a bitmask type
Status
new
Section
[depr.locale.stdcvt]
Submitter
Jonathan Wakely

Created on 2015-06-08.00:00:00 last changed 107 months ago

Messages

Date: 2015-06-08.00:00:00

The enumeration type codecvt_mode is effectively a bitmask type ([bitmask.types]) with three elements, but isn't defined as such.

This harms usability because bitmask types are required to work well with bitwise operators, but codecvt_mode doesn't have overloaded operators, making it very inconvenient to combine values:

std::codecvt_utf16<char32_t, 0x10FFFF,
  static_cast<std::codecvt_mode>(std::little_endian|std::generate_header)>
cvt;

The static_cast harms readability and should not be necessary.

I suggest that either codecvt_mode is specified to be a bitmask type, or as a minimal fix we provide an overloaded operator| that returns the right type.

History
Date User Action Args
2015-06-08 00:00:00admincreate