Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions stl/inc/ostream
Original file line number Diff line number Diff line change
Expand Up @@ -912,15 +912,49 @@ basic_ostream<char, _Traits>& operator<<(
}

#ifdef __cpp_char8_t // These deleted overloads are specified in P1423.
Comment thread
CaseyCarter marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers: This means the char8_t overloads continue to be deleted even in sub-C++20 mode (e.g., if compiling with e.g. /std:c++17 /Zc:char8_t). I'm fine with this inconsistent behavior of char8_t vs. char16_t/char32_t, shout if you are not.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, in any case only "he who likes pain" will use char8_t in C++20... Now, where is that Jens Gustedt pdf on modern C ... sorry talking to myself, have to go now... Good work Casey, thanks a lot, see you ...

// don't insert a UTF-8 NTBS
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(
basic_ostream<char, _Traits>&, const char8_t*) = delete; // don't insert a UTF-8 NTBS
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;

// don't insert a UTF-8 code unit
Comment thread
miscco marked this conversation as resolved.
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(
basic_ostream<char, _Traits>&, char8_t) = delete; // don't insert a UTF-8 code unit
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
#endif // __cpp_char8_t

#if !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20
#ifdef _NATIVE_WCHAR_T_DEFINED
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;

template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
#endif // _NATIVE_WCHAR_T_DEFINED

template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;

template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;

template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;

template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
#endif // !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20

template <class _Ostr, class _Ty, class = void>
struct _Can_stream_out : false_type {};

Expand Down
9 changes: 8 additions & 1 deletion stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
// P1227R2 Signed std::ssize(), Unsigned span::size()
// P1357R1 is_bounded_array, is_unbounded_array
// P1394R4 Range Constructor For span
// P1423R3 char8_t Backward Compatibility Remediation
// P1456R1 Move-Only Views
// P1612R1 Relocating endian To <bit>
// P1645R1 constexpr For <numeric> Algorithms
Expand Down Expand Up @@ -585,6 +586,12 @@
#endif // _M_FP_EXCEPT
#endif // _STD_VECTORIZE_WITH_FLOAT_CONTROL

// P1423R3 char8_t Backward Compatibility Remediation
// Controls whether we allow the stream insertions this proposal forbids
#ifndef _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20
#define _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 (!_HAS_CXX20)
#endif // _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20

// P0174R2 Deprecating Vestigial Library Parts
// P0521R0 Deprecating shared_ptr::unique()
// Other C++17 deprecation warnings
Expand Down Expand Up @@ -1007,7 +1014,7 @@
#define __cpp_lib_bounded_array_traits 201902L

#ifdef __cpp_char8_t
#define __cpp_lib_char8_t 201811L
#define __cpp_lib_char8_t 201907L
Comment thread
StephanTLavavej marked this conversation as resolved.
#endif // __cpp_char8_t

#if defined(__cpp_concepts) && __cpp_concepts > 201507L
Expand Down
7 changes: 7 additions & 0 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ containers\unord\unord.set\insert_and_emplace_allocator_requirements.pass.cpp
# See https://reviews.llvm.org/D73138
containers\views\span.sub\subspan.pass.cpp

# libcxx doesn't yet implement P1423R3, so it expects an "old" value for __cpp_lib_char8_t
language.support\support.limits\support.limits.general\filesystem.version.pass.cpp
language.support\support.limits\support.limits.general\istream.version.pass.cpp
language.support\support.limits\support.limits.general\limits.version.pass.cpp
language.support\support.limits\support.limits.general\locale.version.pass.cpp
language.support\support.limits\support.limits.general\ostream.version.pass.cpp


# *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX ***
# Tracked by VSO-593630 "<filesystem> Enable libcxx filesystem tests"
Expand Down