When is std::codecvt<char, char, std::mbstate_t>::always_noconv() required to return true?

212 views Asked by At

Does the standard (C++17) mandate that std::codecvt<char, char, std::mbstate_t>::always_noconv() returns true

  • for all locales, or
  • for locales provided by the implementation, or
  • only for the C locale, or
  • something else?

The C++ standard does have something to say about it. From section 25.4.1.4 of C++17:

codecvt<char, char, mbstate_t> implements a degenerate conversion; it does not convert at all.

Taken out of context, this strongly suggests that it applies to all locales. Still, I'd appreciate hearing from anybody that can confirm it, or has arguments for why it should not be the case.

1

There are 1 answers

0
Kristian Spangsege On BEST ANSWER

Ok, as was pointed out by cpplearner, the standard (C++17) also has the following text in the requirements for do_always_noconv() in section 25.4.1.4.2:

codecvt<char,char, mbstate_t> returns true.

If the text had instead been:

The specialization codecvt<char,char, mbstate_t> returns true.

I would no longer have any doubt.

However, since this is indeed how similar statements are phrased under other functions in section 25.4.1.4.2, I take it that the intention is to require, that in the codecvt<char,char, mbstate_t> specialization, always_noconv() returns true.

It follows then, that it is the case for all locales.