зеркало из https://github.com/microsoft/STL.git
Reduce inclusion for `<queue>`, `<stack>`, `<stacktrace>`, and `<thread>` (#5003)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
This commit is contained in:
Родитель
5bb81f6cb9
Коммит
37120edc7b
|
@ -20,6 +20,7 @@ set(HEADERS
|
|||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_ostream.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_print.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_ranges_to.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_ranges_tuple_formatter.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_sanitizer_annotate_container.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_string_view.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_system_error_abi.hpp
|
||||
|
|
|
@ -123,6 +123,8 @@ struct _Dynamic_format_specs : _Basic_format_specs<_CharT> {
|
|||
int _Dynamic_precision_index = -1;
|
||||
};
|
||||
|
||||
[[noreturn]] inline void _Throw_format_error(const char* _Message);
|
||||
|
||||
_EXPORT_STD template <class _CharT>
|
||||
class basic_format_parse_context;
|
||||
|
||||
|
@ -398,6 +400,45 @@ constexpr bool enable_nonlocking_formatter_optimization<pair<_Ty1, _Ty2>> =
|
|||
template <class... _Ts>
|
||||
constexpr bool enable_nonlocking_formatter_optimization<tuple<_Ts...>> =
|
||||
(enable_nonlocking_formatter_optimization<_Ts> && ...);
|
||||
|
||||
template <class _CharT>
|
||||
struct _Fill_align_and_width_specs {
|
||||
int _Width = -1;
|
||||
int _Dynamic_width_index = -1;
|
||||
_Fmt_align _Alignment = _Fmt_align::_None;
|
||||
uint8_t _Fill_length = 1;
|
||||
// At most one codepoint (so one char32_t or four utf-8 char8_t).
|
||||
_CharT _Fill[4 / sizeof(_CharT)]{' '};
|
||||
};
|
||||
|
||||
// TRANSITION, VSO-1236041: Avoid declaring and defining member functions in different headers.
|
||||
template <class _CharT, class _Pc>
|
||||
_NODISCARD constexpr _Pc::iterator _Fill_align_and_width_formatter_parse(
|
||||
_Fill_align_and_width_specs<_CharT>& _Specs, _Pc& _Parse_ctx);
|
||||
|
||||
template <class _CharT, class _FormatContext, class _Func>
|
||||
_NODISCARD _FormatContext::iterator _Fill_align_and_width_formatter_format(
|
||||
const _Fill_align_and_width_specs<_CharT>& _Specs, _FormatContext& _Format_ctx, int _Width,
|
||||
_Fmt_align _Default_align, _Func&& _Fn);
|
||||
|
||||
template <class _CharT>
|
||||
struct _Fill_align_and_width_formatter {
|
||||
public:
|
||||
template <class _ParseContext = basic_format_parse_context<_CharT>> // improves throughput, see GH-5003
|
||||
_NODISCARD constexpr _ParseContext::iterator _Parse(type_identity_t<_ParseContext&> _Parse_ctx) {
|
||||
return _STD _Fill_align_and_width_formatter_parse(_Specs, _Parse_ctx);
|
||||
}
|
||||
|
||||
template <class _FormatContext, class _Func>
|
||||
_NODISCARD constexpr auto _Format(
|
||||
_FormatContext& _Format_ctx, const int _Width, _Fmt_align _Default_align, _Func&& _Fn) const {
|
||||
return _STD _Fill_align_and_width_formatter_format(
|
||||
_Specs, _Format_ctx, _Width, _Default_align, _STD forward<_Func>(_Fn));
|
||||
}
|
||||
|
||||
private:
|
||||
_Fill_align_and_width_specs<_CharT> _Specs;
|
||||
};
|
||||
#endif // _HAS_CXX23
|
||||
_STD_END
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1589
stl/inc/format
1589
stl/inc/format
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,6 +18,7 @@
|
|||
"__msvc_ostream.hpp",
|
||||
"__msvc_print.hpp",
|
||||
"__msvc_ranges_to.hpp",
|
||||
"__msvc_ranges_tuple_formatter.hpp",
|
||||
"__msvc_sanitizer_annotate_container.hpp",
|
||||
"__msvc_string_view.hpp",
|
||||
"__msvc_system_error_abi.hpp",
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#if _HAS_CXX23
|
||||
#include <__msvc_ranges_to.hpp>
|
||||
#include <format>
|
||||
#include <__msvc_ranges_tuple_formatter.hpp>
|
||||
#include <iterator>
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#if _HAS_CXX23
|
||||
#include <__msvc_ranges_to.hpp>
|
||||
#include <format>
|
||||
#include <__msvc_ranges_tuple_formatter.hpp>
|
||||
#include <iterator>
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
_EMIT_STL_WARNING(STL4038, "The contents of <stacktrace> are available only with C++23 or later.");
|
||||
#else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv
|
||||
|
||||
#include <__msvc_formatter.hpp>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
@ -341,7 +341,8 @@ ostream& operator<<(ostream& _Os, const basic_stacktrace<_Alloc>& _St) {
|
|||
|
||||
template <>
|
||||
struct formatter<stacktrace_entry> {
|
||||
constexpr format_parse_context::iterator parse(format_parse_context& _Parse_ctx) {
|
||||
template <class _ParseContext = basic_format_parse_context<char>> // improves throughput, see GH-5003
|
||||
constexpr _ParseContext::iterator parse(type_identity_t<_ParseContext&> _Parse_ctx) {
|
||||
return _Impl._Parse(_Parse_ctx);
|
||||
}
|
||||
|
||||
|
@ -361,7 +362,8 @@ inline constexpr bool enable_nonlocking_formatter_optimization<stacktrace_entry>
|
|||
|
||||
template <class _Alloc>
|
||||
struct formatter<basic_stacktrace<_Alloc>> {
|
||||
constexpr format_parse_context::iterator parse(format_parse_context& _Parse_ctx) {
|
||||
template <class _ParseContext = basic_format_parse_context<char>> // improves throughput, see GH-5003
|
||||
constexpr _ParseContext::iterator parse(type_identity_t<_ParseContext&> _Parse_ctx) {
|
||||
const auto _First = _Parse_ctx.begin();
|
||||
if (_First != _Parse_ctx.end() && *_First != '}') {
|
||||
_Throw_format_error("For formatter<basic_stacktrace<Allocator>>, format-spec must be empty.");
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#endif // _HAS_CXX20
|
||||
|
||||
#if _HAS_CXX23
|
||||
#include <format>
|
||||
#include <__msvc_formatter.hpp>
|
||||
#endif // _HAS_CXX23
|
||||
|
||||
#pragma pack(push, _CRT_PACKING)
|
||||
|
@ -309,11 +309,8 @@ basic_ostream<_Ch, _Tr>& operator<<(basic_ostream<_Ch, _Tr>& _Str, thread::id _I
|
|||
// constrained to character types supported by `format`.
|
||||
template <_Format_supported_charT _CharT>
|
||||
struct formatter<thread::id, _CharT> {
|
||||
private:
|
||||
using _Pc = basic_format_parse_context<_CharT>;
|
||||
|
||||
public:
|
||||
constexpr _Pc::iterator parse(_Pc& _Parse_ctx) {
|
||||
template <class _Pc = basic_format_parse_context<_CharT>> // improves throughput, see GH-5003
|
||||
constexpr _Pc::iterator parse(type_identity_t<_Pc&> _Parse_ctx) {
|
||||
return _Impl._Parse(_Parse_ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -627,6 +627,9 @@ tests\P2286R8_text_formatting_escaping
|
|||
tests\P2286R8_text_formatting_escaping_legacy_text_encoding
|
||||
tests\P2286R8_text_formatting_escaping_utf8
|
||||
tests\P2286R8_text_formatting_formattable
|
||||
tests\P2286R8_text_formatting_header_queue
|
||||
tests\P2286R8_text_formatting_header_stack
|
||||
tests\P2286R8_text_formatting_header_vector
|
||||
tests\P2286R8_text_formatting_range_formatter
|
||||
tests\P2286R8_text_formatting_range_map
|
||||
tests\P2286R8_text_formatting_range_sequence
|
||||
|
@ -682,6 +685,8 @@ tests\P2517R1_apply_conditional_noexcept
|
|||
tests\P2538R1_adl_proof_std_projected
|
||||
tests\P2609R3_relaxing_ranges_just_a_smidge
|
||||
tests\P2693R1_ostream_and_thread_id
|
||||
tests\P2693R1_text_formatting_header_stacktrace
|
||||
tests\P2693R1_text_formatting_header_thread
|
||||
tests\P2693R1_text_formatting_stacktrace
|
||||
tests\P2693R1_text_formatting_thread_id
|
||||
tests\P3107R5_enabled_specializations
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\usual_latest_matrix.lst
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// intentionally avoid including <format> to verify that the formatter specializations are defined in <queue>
|
||||
|
||||
#include <concepts>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct cannot_format {
|
||||
friend auto operator<=>(cannot_format, cannot_format) = default;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void verify_semiregularity_for() {
|
||||
static_assert(semiregular<T>);
|
||||
|
||||
T x;
|
||||
T y = x;
|
||||
T z = move(x);
|
||||
x = y;
|
||||
x = move(z);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void verify_disabled_for() {
|
||||
static_assert(!is_default_constructible_v<T>);
|
||||
static_assert(!is_copy_constructible_v<T>);
|
||||
static_assert(!is_move_constructible_v<T>);
|
||||
static_assert(!is_copy_assignable_v<T>);
|
||||
static_assert(!is_move_assignable_v<T>);
|
||||
}
|
||||
|
||||
void verify_formatters() {
|
||||
verify_semiregularity_for<formatter<queue<int>, char>>();
|
||||
verify_semiregularity_for<formatter<queue<int>, wchar_t>>();
|
||||
verify_semiregularity_for<formatter<queue<int, pmr::deque<int>>, char>>();
|
||||
verify_semiregularity_for<formatter<queue<int, pmr::deque<int>>, wchar_t>>();
|
||||
|
||||
verify_semiregularity_for<formatter<priority_queue<int>, char>>();
|
||||
verify_semiregularity_for<formatter<priority_queue<int>, wchar_t>>();
|
||||
verify_semiregularity_for<formatter<priority_queue<int, vector<int>, greater<>>, char>>();
|
||||
verify_semiregularity_for<formatter<priority_queue<int, vector<int>, greater<>>, wchar_t>>();
|
||||
verify_semiregularity_for<formatter<priority_queue<int, pmr::vector<int>>, char>>();
|
||||
verify_semiregularity_for<formatter<priority_queue<int, pmr::vector<int>>, wchar_t>>();
|
||||
|
||||
verify_disabled_for<formatter<queue<cannot_format>, char>>();
|
||||
verify_disabled_for<formatter<queue<cannot_format>, wchar_t>>();
|
||||
verify_disabled_for<formatter<queue<cannot_format, pmr::deque<cannot_format>>, char>>();
|
||||
verify_disabled_for<formatter<queue<cannot_format, pmr::deque<cannot_format>>, wchar_t>>();
|
||||
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format>, char>>();
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format>, wchar_t>>();
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format, vector<cannot_format>, greater<>>, char>>();
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format, vector<cannot_format>, greater<>>, wchar_t>>();
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format, pmr::vector<cannot_format>>, char>>();
|
||||
verify_disabled_for<formatter<priority_queue<cannot_format, pmr::vector<cannot_format>>, wchar_t>>();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\usual_latest_matrix.lst
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// intentionally avoid including <format> to verify that the formatter specialization is defined in <stack>
|
||||
|
||||
#include <concepts>
|
||||
#include <deque>
|
||||
#include <stack>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct cannot_format {};
|
||||
|
||||
template <class T>
|
||||
void verify_semiregularity_for() {
|
||||
static_assert(semiregular<T>);
|
||||
|
||||
T x;
|
||||
T y = x;
|
||||
T z = move(x);
|
||||
x = y;
|
||||
x = move(z);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void verify_disabled_for() {
|
||||
static_assert(!is_default_constructible_v<T>);
|
||||
static_assert(!is_copy_constructible_v<T>);
|
||||
static_assert(!is_move_constructible_v<T>);
|
||||
static_assert(!is_copy_assignable_v<T>);
|
||||
static_assert(!is_move_assignable_v<T>);
|
||||
}
|
||||
|
||||
void verify_formatters() {
|
||||
verify_semiregularity_for<formatter<stack<int>, char>>();
|
||||
verify_semiregularity_for<formatter<stack<int>, wchar_t>>();
|
||||
verify_semiregularity_for<formatter<stack<int, pmr::deque<int>>, char>>();
|
||||
verify_semiregularity_for<formatter<stack<int, pmr::deque<int>>, wchar_t>>();
|
||||
|
||||
verify_disabled_for<formatter<stack<cannot_format>, char>>();
|
||||
verify_disabled_for<formatter<stack<cannot_format>, wchar_t>>();
|
||||
verify_disabled_for<formatter<stack<cannot_format, pmr::deque<cannot_format>>, char>>();
|
||||
verify_disabled_for<formatter<stack<cannot_format, pmr::deque<cannot_format>>, wchar_t>>();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\usual_latest_matrix.lst
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// intentionally avoid including <format> to verify that the formatter specialization is defined in <vector>
|
||||
|
||||
#include <concepts>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
void verify_semiregularity_for() {
|
||||
static_assert(semiregular<T>);
|
||||
|
||||
T x;
|
||||
T y = x;
|
||||
T z = move(x);
|
||||
x = y;
|
||||
x = move(z);
|
||||
}
|
||||
|
||||
void verify_formatters() {
|
||||
verify_semiregularity_for<formatter<vector<bool>::reference, char>>();
|
||||
verify_semiregularity_for<formatter<vector<bool>::reference, wchar_t>>();
|
||||
verify_semiregularity_for<formatter<pmr::vector<bool>::reference, char>>();
|
||||
verify_semiregularity_for<formatter<pmr::vector<bool>::reference, wchar_t>>();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\usual_latest_matrix.lst
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// intentionally avoid including <format> to verify that the formatter specializations are defined in <stacktrace>
|
||||
|
||||
#include <concepts>
|
||||
#include <stacktrace>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
void verify_semiregularity_for() {
|
||||
static_assert(semiregular<T>);
|
||||
|
||||
T x;
|
||||
T y = x;
|
||||
T z = move(x);
|
||||
x = y;
|
||||
x = move(z);
|
||||
}
|
||||
|
||||
void verify_formatters() {
|
||||
verify_semiregularity_for<formatter<stacktrace_entry, char>>();
|
||||
verify_semiregularity_for<formatter<stacktrace, char>>();
|
||||
verify_semiregularity_for<formatter<pmr::stacktrace, char>>();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\usual_latest_matrix.lst
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// intentionally avoid including <format> to verify that the formatter specialization is defined in <thread>
|
||||
|
||||
#include <concepts>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
void verify_semiregularity_for() {
|
||||
static_assert(semiregular<T>);
|
||||
|
||||
T x;
|
||||
T y = x;
|
||||
T z = move(x);
|
||||
x = y;
|
||||
x = move(z);
|
||||
}
|
||||
|
||||
void verify_formatters() {
|
||||
verify_semiregularity_for<formatter<thread::id, char>>();
|
||||
verify_semiregularity_for<formatter<thread::id, wchar_t>>();
|
||||
}
|
Загрузка…
Ссылка в новой задаче