зеркало из https://github.com/microsoft/STL.git
<expected> Implement P0323R12 (#2643)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com> Co-authored-by: Casey Carter <Casey@Carter.net>
This commit is contained in:
Родитель
1a20fe1133
Коммит
b7ba3ad82f
|
@ -131,6 +131,7 @@ set(HEADERS
|
|||
${CMAKE_CURRENT_LIST_DIR}/inc/deque
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/exception
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/execution
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/expected
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/coroutine
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/deque
|
||||
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/filesystem
|
||||
|
|
|
@ -247,6 +247,45 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|||
</Type>
|
||||
|
||||
|
||||
<Type Name="std::unexpected<*>">
|
||||
<Intrinsic Name="unex" Expression="_Unexpected"/>
|
||||
<DisplayString>{unex()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="unex">unex()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="std::bad_expected_access<*>">
|
||||
<Intrinsic Name="unex" Expression="_Unexpected"/>
|
||||
<DisplayString>{unex()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="unex">unex()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="std::expected<*,*>">
|
||||
<Intrinsic Name="has_value" Expression="_Has_value"/>
|
||||
<Intrinsic Name="value" Expression="_Value"/>
|
||||
<Intrinsic Name="unex" Expression="_Unexpected"/>
|
||||
<DisplayString Condition="has_value()">{value()}</DisplayString>
|
||||
<DisplayString Condition="!has_value()">{unex()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Condition="has_value()" Name="value">value()</Item>
|
||||
<Item Condition="!has_value()" Name="unex">unex()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="std::expected<void,*>">
|
||||
<Intrinsic Name="has_value" Expression="_Has_value"/>
|
||||
<Intrinsic Name="unex" Expression="_Unexpected"/>
|
||||
<DisplayString Condition="has_value()">void</DisplayString>
|
||||
<DisplayString Condition="!has_value()">{unex()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Condition="!has_value()" Name="unex">unex()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
|
||||
<Type Name="std::bitset<*>">
|
||||
<DisplayString>{{ size={$T1} }}</DisplayString>
|
||||
<Expand>
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
#include <complex>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <forward_list>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -55,6 +55,7 @@
|
|||
"deque",
|
||||
"exception",
|
||||
"execution",
|
||||
"expected",
|
||||
"filesystem",
|
||||
"format",
|
||||
"forward_list",
|
||||
|
|
|
@ -281,6 +281,7 @@
|
|||
|
||||
// _HAS_CXX23 directly controls:
|
||||
// P0288R9 move_only_function
|
||||
// P0323R12 <expected>
|
||||
// P0401R6 Providing Size Feedback In The Allocator Interface
|
||||
// P0448R4 <spanstream>
|
||||
// P0627R6 unreachable()
|
||||
|
@ -307,6 +308,7 @@
|
|||
// (changes to pair, tuple, and vector<bool>::reference only)
|
||||
// P2442R1 Windowing Range Adaptors: views::chunk, views::slide
|
||||
// P2443R1 views::chunk_by
|
||||
// P2549R0 unexpected<E>::error()
|
||||
|
||||
// Parallel Algorithms Notes
|
||||
// C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms.
|
||||
|
@ -1438,9 +1440,14 @@
|
|||
|
||||
#define __cpp_lib_associative_heterogeneous_erasure 202110L
|
||||
#define __cpp_lib_byteswap 202110L
|
||||
#define __cpp_lib_invoke_r 202106L
|
||||
#define __cpp_lib_is_scoped_enum 202011L
|
||||
#define __cpp_lib_move_only_function 202110L
|
||||
|
||||
#ifdef __cpp_lib_concepts
|
||||
#define __cpp_lib_expected 202202L
|
||||
#endif // __cpp_lib_concepts
|
||||
|
||||
#define __cpp_lib_invoke_r 202106L
|
||||
#define __cpp_lib_is_scoped_enum 202011L
|
||||
#define __cpp_lib_move_only_function 202110L
|
||||
|
||||
#ifdef __cpp_lib_concepts
|
||||
#define __cpp_lib_out_ptr 202106L
|
||||
|
|
|
@ -257,6 +257,7 @@ tests\P0220R1_searchers
|
|||
tests\P0220R1_string_view
|
||||
tests\P0288R9_move_only_function
|
||||
tests\P0295R0_gcd_lcm
|
||||
tests\P0323R12_expected
|
||||
tests\P0325R4_to_array
|
||||
tests\P0339R6_polymorphic_allocator
|
||||
tests\P0355R7_calendars_and_time_zones_clocks
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
RUNALL_INCLUDE ..\strict_concepts_latest_matrix.lst
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -21,6 +21,7 @@
|
|||
"deque",
|
||||
"exception",
|
||||
"execution",
|
||||
"expected",
|
||||
"filesystem",
|
||||
"format",
|
||||
"forward_list",
|
||||
|
|
|
@ -28,6 +28,9 @@ import <coroutine>;
|
|||
import <deque>;
|
||||
import <exception>;
|
||||
import <execution>;
|
||||
#ifdef _MSVC_INTERNAL_TESTING // TRANSITION, VSO-1543660 fixed in 17.3 Preview 3
|
||||
import <expected>;
|
||||
#endif // ^^^ no workaround ^^^
|
||||
import <filesystem>;
|
||||
import <format>;
|
||||
import <forward_list>;
|
||||
|
@ -258,8 +261,8 @@ int main() {
|
|||
odd.join();
|
||||
even.join();
|
||||
|
||||
const vector<int> expected = {5, 51, 512, 5121, 51212, 512121, 5121212};
|
||||
assert(vec == expected);
|
||||
const vector<int> expected_val = {5, 51, 512, 5121, 51212, 512121, 5121212};
|
||||
assert(vec == expected_val);
|
||||
|
||||
static_assert(static_cast<int>(cv_status::no_timeout) == 0);
|
||||
static_assert(static_cast<int>(cv_status::timeout) == 1);
|
||||
|
@ -291,6 +294,14 @@ int main() {
|
|||
assert(count(execution::par, begin(arr), end(arr), 0) == 4);
|
||||
}
|
||||
|
||||
#ifdef _MSVC_INTERNAL_TESTING // TRANSITION, VSO-1543660 fixed in 17.3 Preview 3
|
||||
{
|
||||
puts("Testing <expected>.");
|
||||
constexpr expected<double, int> test{unexpect, 42};
|
||||
assert(test.error() == 42);
|
||||
}
|
||||
#endif // ^^^ no workaround ^^^
|
||||
|
||||
{
|
||||
puts("Testing <filesystem>.");
|
||||
constexpr wstring_view dot{L"."};
|
||||
|
@ -601,8 +612,8 @@ int main() {
|
|||
v.push_back(it->str());
|
||||
}
|
||||
|
||||
const vector<string> expected{"cute", "fluffy", "kittens"};
|
||||
assert(v == expected);
|
||||
const vector<string> expected_val{"cute", "fluffy", "kittens"};
|
||||
assert(v == expected_val);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -611,8 +622,8 @@ int main() {
|
|||
v.push_back(11);
|
||||
v.push_back(22);
|
||||
v.push_back(33);
|
||||
constexpr int expected[]{11, 22, 33};
|
||||
assert(equal(v.begin(), v.end(), begin(expected), end(expected)));
|
||||
constexpr int expected_val[]{11, 22, 33};
|
||||
assert(equal(v.begin(), v.end(), begin(expected_val), end(expected_val)));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -682,8 +693,8 @@ int main() {
|
|||
odd.join();
|
||||
even.join();
|
||||
|
||||
const vector<int> expected = {5, 51, 512, 5121, 51212, 512121, 5121212};
|
||||
assert(vec == expected);
|
||||
const vector<int> expected_val = {5, 51, 512, 5121, 51212, 512121, 5121212};
|
||||
assert(vec == expected_val);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -706,31 +717,31 @@ int main() {
|
|||
char ibuffer[] = "1 2 3 4 5";
|
||||
ispanstream is{span<char>{ibuffer}};
|
||||
int read = 0;
|
||||
for (int expected = 1; expected <= 5; ++expected) {
|
||||
for (int expected_val = 1; expected_val <= 5; ++expected_val) {
|
||||
assert(is.good());
|
||||
is >> read;
|
||||
assert(read == expected);
|
||||
assert(read == expected_val);
|
||||
}
|
||||
|
||||
const char const_buffer[] = "1 2 3 4 5";
|
||||
basic_ispanstream<char> is_const_buffer{span<const char>{const_buffer}};
|
||||
read = 0;
|
||||
for (int expected = 1; expected <= 5; ++expected) {
|
||||
for (int expected_val = 1; expected_val <= 5; ++expected_val) {
|
||||
assert(is_const_buffer.good());
|
||||
is_const_buffer >> read;
|
||||
assert(read == expected);
|
||||
assert(read == expected_val);
|
||||
}
|
||||
|
||||
const auto expected = "102030"sv;
|
||||
const auto expected_val = "102030"sv;
|
||||
char obuffer[10];
|
||||
ospanstream os{span<char>{obuffer}};
|
||||
os << 10 << 20 << 30;
|
||||
assert(equal(begin(os.span()), end(os.span()), begin(expected), end(expected)));
|
||||
assert(equal(begin(os.span()), end(os.span()), begin(expected_val), end(expected_val)));
|
||||
|
||||
char buffer[10];
|
||||
spanstream s{span<char>{buffer}};
|
||||
s << 10 << 20 << 30;
|
||||
assert(equal(begin(s.span()), end(s.span()), begin(expected), end(expected)));
|
||||
assert(equal(begin(s.span()), end(s.span()), begin(expected_val), end(expected_val)));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -799,13 +810,13 @@ int main() {
|
|||
}};
|
||||
l.wait(); // wait for jt to generate the sequence
|
||||
} // destroying jt will ask it to stop
|
||||
static constexpr int expected[]{1729, 5188, 2594, 1297, 3892, 1946, 973, 2920, 1460, 730, 365, 1096, 548, 274,
|
||||
137, 412, 206, 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336,
|
||||
668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158,
|
||||
1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308,
|
||||
1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160,
|
||||
80, 40, 20, 10, 5, 16, 8, 4, 2, 1, -1000};
|
||||
assert(equal(vec.begin(), vec.end(), begin(expected), end(expected)));
|
||||
static constexpr int expected_val[]{1729, 5188, 2594, 1297, 3892, 1946, 973, 2920, 1460, 730, 365, 1096, 548,
|
||||
274, 137, 412, 206, 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445,
|
||||
1336, 668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719,
|
||||
2158, 1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616,
|
||||
2308, 1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53,
|
||||
160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1, -1000};
|
||||
assert(equal(vec.begin(), vec.end(), begin(expected_val), end(expected_val)));
|
||||
}
|
||||
#endif // ^^^ no workaround ^^^
|
||||
|
||||
|
|
|
@ -714,6 +714,20 @@ STATIC_ASSERT(__cpp_lib_execution == 201603L);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if _HAS_CXX23 && !defined(__EDG__) // TRANSITION, EDG concepts support
|
||||
#ifndef __cpp_lib_expected
|
||||
#error __cpp_lib_expected is not defined
|
||||
#elif __cpp_lib_expected != 202202L
|
||||
#error __cpp_lib_expected is not 202202L
|
||||
#else
|
||||
STATIC_ASSERT(__cpp_lib_expected == 202202L);
|
||||
#endif
|
||||
#else
|
||||
#ifdef __cpp_lib_expected
|
||||
#error __cpp_lib_expected is defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __cpp_lib_experimental_erase_if
|
||||
#error __cpp_lib_experimental_erase_if is not defined
|
||||
#elif __cpp_lib_experimental_erase_if != 201411L
|
||||
|
|
|
@ -24,6 +24,7 @@ PM_CL="/DMEOW_HEADER=coroutine"
|
|||
PM_CL="/DMEOW_HEADER=deque"
|
||||
PM_CL="/DMEOW_HEADER=exception"
|
||||
PM_CL="/DMEOW_HEADER=execution"
|
||||
PM_CL="/DMEOW_HEADER=expected"
|
||||
PM_CL="/DMEOW_HEADER=filesystem"
|
||||
PM_CL="/DMEOW_HEADER=format"
|
||||
PM_CL="/DMEOW_HEADER=forward_list"
|
||||
|
|
Загрузка…
Ссылка в новой задаче