[diff.cpp17.input.output] (original) (raw)
Annex C (informative) Compatibility [diff]
C.3 C++ and ISO C++ 2017 [diff.cpp17]
C.3.14 [input.output]: input/output library [diff.cpp17.input.output]
Affected subclause: [istream.extractors]
Change: Character array extraction only takes array types.
Rationale: Increase safety via preventing buffer overflow at compile time.
Effect on original feature: Valid C++ 2017 code may fail to compile in this revision of C++.
[Example 1: auto p = new char[100];char q[100]; std::cin >> std::setw(20) >> p; std::cin >> std::setw(20) >> q; — _end example_]
Affected subclause: [ostream.inserters.character]
Change: Overload resolution for ostream inserters used with UTF-8 literals.
Rationale: Required for new features.
Effect on original feature: Valid C++ 2017 code that passes UTF-8 literals tobasic_ostream<char, ...>::operator<< orbasic_ostream<wchar_t, ...>::operator<< is now ill-formed.
[Example 2: std::cout << u8"text"; std::cout << u8'X'; — _end example_]
Affected subclause: [ostream.inserters.character]
Change: Overload resolution for ostream inserters used with wchar_t, char16_t, or char32_t types.
Rationale: Removal of surprising behavior.
Effect on original feature: Valid C++ 2017 code that passeswchar_t, char16_t, or char32_t characters or strings to basic_ostream<char, ...>::operator<< or that passes char16_t or char32_t characters or strings to basic_ostream<wchar_t, ...>::operator<< is now ill-formed.
[Example 3: std::cout << u"text"; std::cout << u'X'; — _end example_]
Affected subclause: [fs.class.path]
Change: Return type of filesystem path format observer member functions.
Rationale: Required for new features.
Effect on original feature: Valid C++ 2017 code that depends on the u8string() andgeneric_u8string() member functions of std::filesystem::pathreturning std::string is not valid in this revision of C++.
[Example 4: std::filesystem::path p; std::string s1 = p.u8string(); std::string s2 = p.generic_u8string(); — _end example_]