Skip to content
12 changes: 12 additions & 0 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -4774,6 +4774,18 @@ public:
private:
_Fill_align_and_width_specs<_CharT> _Specs;
};

template <class _Adaptor>
consteval auto _Get_member_pointer_to_adapted_container() noexcept {
struct _Container_exposer : _Adaptor {
using _Adaptor::c;

_Container_exposer(const _Container_exposer&) = delete;
_Container_exposer& operator=(const _Container_exposer&) = delete;
~_Container_exposer() = delete;
};
return &_Container_exposer::c;
}
#endif // _HAS_CXX23
_STD_END

Expand Down
52 changes: 52 additions & 0 deletions stl/inc/queue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#if _HAS_CXX23
#include <__msvc_ranges_to.hpp>
#include <format>
#include <iterator>
#endif // _HAS_CXX23

Expand Down Expand Up @@ -223,6 +224,31 @@ void swap(queue<_Ty, _Container>& _Left, queue<_Ty, _Container>& _Right) noexcep
template <class _Ty, class _Container, class _Alloc>
struct uses_allocator<queue<_Ty, _Container>, _Alloc> : uses_allocator<_Container, _Alloc>::type {};

#if _HAS_CXX23
// Per LWG-3997, `_CharT` in library-provided `formatter` specializations is
// constrained to character types supported by `format`.
template <_Format_supported_charT _CharT, class _Ty, formattable<_CharT> _Container>
struct formatter<queue<_Ty, _Container>, _CharT> {
private:
using _Maybe_const_container = _Fmt_maybe_const<_Container, _CharT>;
using _Maybe_const_adaptor = _Maybe_const<is_const_v<_Maybe_const_container>, queue<_Ty, _Container>>;

formatter<_RANGES ref_view<_Maybe_const_container>, _CharT> _Underlying;

public:
template <class _ParseCtx>
constexpr _ParseCtx::iterator parse(_ParseCtx& _Ctx) {
return _Underlying.parse(_Ctx);
}

template <class _FmtCtx>
_FmtCtx::iterator format(_Maybe_const_adaptor& _Adaptor, _FmtCtx& _Ctx) const {
constexpr auto _Mem_cont_ptr = _STD _Get_member_pointer_to_adapted_container<queue<_Ty, _Container>>();
return _Underlying.format(_Adaptor.*_Mem_cont_ptr, _Ctx);
}
};
#endif // _HAS_CXX23

_EXPORT_STD template <class _Ty, class _Container = vector<_Ty>, class _Pr = less<typename _Container::value_type>>
class priority_queue {
public:
Expand Down Expand Up @@ -490,6 +516,32 @@ void swap(priority_queue<_Ty, _Container, _Pr>& _Left, priority_queue<_Ty, _Cont
template <class _Ty, class _Container, class _Pr, class _Alloc>
struct uses_allocator<priority_queue<_Ty, _Container, _Pr>, _Alloc> : uses_allocator<_Container, _Alloc>::type {};

#if _HAS_CXX23
// Per LWG-3997, `_CharT` in library-provided `formatter` specializations is
// constrained to character types supported by `format`.
template <_Format_supported_charT _CharT, class _Ty, formattable<_CharT> _Container, class _Comp>
struct formatter<priority_queue<_Ty, _Container, _Comp>, _CharT> {
private:
using _Maybe_const_container = _Fmt_maybe_const<_Container, _CharT>;
using _Maybe_const_adaptor =
_Maybe_const<is_const_v<_Maybe_const_container>, priority_queue<_Ty, _Container, _Comp>>;

formatter<_RANGES ref_view<_Maybe_const_container>, _CharT> _Underlying;

public:
template <class _ParseCtx>
constexpr _ParseCtx::iterator parse(_ParseCtx& _Ctx) {
return _Underlying.parse(_Ctx);
}

template <class _FmtCtx>
_FmtCtx::iterator format(_Maybe_const_adaptor& _Adaptor, _FmtCtx& _Ctx) const {
constexpr auto _Mem_cont_ptr =
_STD _Get_member_pointer_to_adapted_container<priority_queue<_Ty, _Container, _Comp>>();
return _Underlying.format(_Adaptor.*_Mem_cont_ptr, _Ctx);
}
};
#endif // _HAS_CXX23
_STD_END

#pragma pop_macro("new")
Expand Down
26 changes: 26 additions & 0 deletions stl/inc/stack
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#if _HAS_CXX23
#include <__msvc_ranges_to.hpp>
#include <format>
#include <iterator>
#endif // _HAS_CXX23

Expand Down Expand Up @@ -209,6 +210,31 @@ void swap(stack<_Ty, _Container>& _Left, stack<_Ty, _Container>& _Right) noexcep

template <class _Ty, class _Container, class _Alloc>
struct uses_allocator<stack<_Ty, _Container>, _Alloc> : uses_allocator<_Container, _Alloc>::type {};

#if _HAS_CXX23
// Per LWG-3997, `_CharT` in library-provided `formatter` specializations is
// constrained to character types supported by `format`.
template <_Format_supported_charT _CharT, class _Ty, formattable<_CharT> _Container>
struct formatter<stack<_Ty, _Container>, _CharT> {
private:
using _Maybe_const_container = _Fmt_maybe_const<_Container, _CharT>;
using _Maybe_const_adaptor = _Maybe_const<is_const_v<_Maybe_const_container>, stack<_Ty, _Container>>;

formatter<_RANGES ref_view<_Maybe_const_container>, _CharT> _Underlying;

public:
template <class _ParseCtx>
constexpr _ParseCtx::iterator parse(_ParseCtx& _Ctx) {
return _Underlying.parse(_Ctx);
}

template <class _FmtCtx>
_FmtCtx::iterator format(_Maybe_const_adaptor& _Adaptor, _FmtCtx& _Ctx) const {
constexpr auto _Mem_cont_ptr = _STD _Get_member_pointer_to_adapted_container<stack<_Ty, _Container>>();
return _Underlying.format(_Adaptor.*_Mem_cont_ptr, _Ctx);
}
};
#endif // _HAS_CXX23
_STD_END

#pragma pop_macro("new")
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
// P2165R4 Compatibility Between tuple, pair, And tuple-like Objects
// P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr
// P2186R2 Removing Garbage Collection Support
// P2286R8 Formatting Ranges
// P2273R3 constexpr unique_ptr
// P2278R4 cbegin Should Always Return A Constant Iterator
// P2286R8 Formatting Ranges
Expand Down Expand Up @@ -383,6 +384,7 @@
// P2539R4 Synchronizing print() With The Underlying Stream
// P2540R1 Empty Product For Certain Views
// P2549R1 unexpected<E>::error()
// P2585R1 Improve Default Container Formatting
// P2599R2 mdspan: index_type, size_type
// P2604R0 mdspan: data_handle_type, data_handle(), exhaustive
// P2613R1 mdspan: empty()
Expand Down Expand Up @@ -1755,6 +1757,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
#define __cpp_lib_constexpr_typeinfo 202106L
#define __cpp_lib_containers_ranges 202202L
#define __cpp_lib_expected 202211L
#define __cpp_lib_format_ranges 202207L
#define __cpp_lib_formatters 202302L
#define __cpp_lib_forward_like 202207L
#define __cpp_lib_freestanding_expected 202311L
Expand Down
9 changes: 1 addition & 8 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ std/language.support/support.limits/support.limits.general/cstdlib.version.compi
# P2255R2 "Type Traits To Detect References Binding To Temporaries"
std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp FAIL

# P2286R8 Formatting Ranges
std/containers/container.adaptors/container.adaptors.format/format.functions.format.pass.cpp FAIL
std/containers/container.adaptors/container.adaptors.format/format.functions.vformat.pass.cpp FAIL
std/containers/container.adaptors/container.adaptors.format/format.pass.cpp FAIL
std/containers/container.adaptors/container.adaptors.format/parse.pass.cpp FAIL
std/containers/container.adaptors/container.adaptors.format/types.compile.pass.cpp FAIL
std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp FAIL


# *** MISSING COMPILER FEATURES ***
# P1169R4 static operator()
Expand Down Expand Up @@ -968,6 +960,7 @@ std/input.output/string.streams/stringstream/stringstream.members/str.allocator_
# These formatter tests need to create basic_format_contexts, so test_format_context.h
# says "Please create a vendor specific version of the test functions".
# If we do, some of these tests should be able to work.
std/containers/container.adaptors/container.adaptors.format/format.pass.cpp FAIL
std/containers/sequences/vector.bool/vector.bool.fmt/format.pass.cpp FAIL
std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp FAIL
std/utilities/format/format.formatter/format.context/format.context/advance_to.pass.cpp FAIL
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ tests\P2278R4_const_span
tests\P2278R4_ranges_const_iterator_machinery
tests\P2278R4_ranges_const_range_machinery
tests\P2278R4_views_as_const
tests\P2286R8_text_formatting_container_adaptors
tests\P2286R8_text_formatting_debug_enabled_specializations
tests\P2286R8_text_formatting_escaping
tests\P2286R8_text_formatting_escaping_legacy_text_encoding
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_latest_matrix.lst
Loading