Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<expected> Implement P0323R12 #2643

Merged
merged 29 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a7b0a1
<expected> Implement P0323: expected
miscco Mar 29, 2022
f1f5ff1
Address review comments
miscco Apr 9, 2022
af61334
Add some transition comments and paper number
miscco Apr 9, 2022
b6300ad
Use guard type rather than try catch blocks
miscco Apr 10, 2022
a6a7c24
Use consistent condition for feature test checks
miscco Apr 11, 2022
366377d
Merge branch 'main' into p0323-expected
miscco Apr 18, 2022
c4e5abd
Address review comments
miscco Apr 18, 2022
e305bfa
More mandates instead of constraints
miscco Apr 19, 2022
64d19d4
Add debugger visualisation as suggested by @SuperWig
miscco Apr 19, 2022
6e0094a
Address review comments
miscco Apr 29, 2022
dcb6544
use is_same_v instead of same_as
CaseyCarter May 1, 2022
d213de9
Merge branch 'main' into p0323-expected
miscco May 2, 2022
3da07d6
Merge branch 'main' into p0323-expected
miscco May 17, 2022
854159d
Drop __cpp_explicit_this_parameter.
StephanTLavavej May 19, 2022
e339374
Code review feedback, fixing several bugs.
StephanTLavavej May 20, 2022
1d8c6e5
Drop tests comparing `expected<void, ...>` to `expected<NonVoid, ...>`.
StephanTLavavej May 20, 2022
4a00d41
Add tests for `expected<void, E>` constructors.
StephanTLavavej May 20, 2022
3198d49
Formatting: Drop `//` within `clang-format off`.
StephanTLavavej May 20, 2022
2b2eff4
Fix formatting damage
miscco May 20, 2022
b5ac746
Do not call trivial destructors
miscco May 20, 2022
3dd480b
Test review feedback.
StephanTLavavej May 20, 2022
86e4f11
Test: Use typedefs to shorten long lines.
StephanTLavavej May 20, 2022
691621a
Rename No to Not.
StephanTLavavej May 20, 2022
4f5cc25
Sort Not/Yes patterns, so they're tested in "binary order" consistently.
StephanTLavavej May 20, 2022
bb06fa1
Add IsYes() to reduce verbosity.
StephanTLavavej May 20, 2022
45a39ec
`expected<void, E>::error()` is now mandated to be noexcept.
StephanTLavavej May 20, 2022
0796610
Work around VSO-1543660.
StephanTLavavej May 21, 2022
2fec1f2
Casey's review comments
CaseyCarter May 23, 2022
bb261ad
Guard `_Old_val.~_Second()`, enable header unit test internally.
StephanTLavavej May 23, 2022
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
1 change: 1 addition & 0 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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
Expand Down
1 change: 1 addition & 0 deletions stl/inc/__msvc_all_public_headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#include <complex>
#include <deque>
#include <exception>
#include <expected>
#include <filesystem>
#include <format>
#include <forward_list>
Expand Down
1,022 changes: 1,022 additions & 0 deletions stl/inc/expected

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions stl/inc/header-units.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"deque",
"exception",
"execution",
"expected",
"filesystem",
"format",
"forward_list",
Expand Down
13 changes: 10 additions & 3 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -303,6 +304,7 @@
// P2186R2 Removing Garbage Collection Support
// P2273R3 constexpr unique_ptr
// P2443R1 views::chunk_by
// P2549R0 unexpected<E>::error()
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved

// Parallel Algorithms Notes
// C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms.
Expand Down Expand Up @@ -1372,9 +1374,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
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ tests\P0220R1_searchers
tests\P0220R1_string_view
tests\P0288R9_move_only_function
tests\P0295R0_gcd_lcm
tests\P0323R12_expected
miscco marked this conversation as resolved.
Show resolved Hide resolved
tests\P0325R4_to_array
tests\P0339R6_polymorphic_allocator
tests\P0355R7_calendars_and_time_zones_clocks
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/P0323R12_expected/env.lst
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 ..\strict_concepts_latest_matrix.lst
miscco marked this conversation as resolved.
Show resolved Hide resolved
1,865 changes: 1,865 additions & 0 deletions tests/std/tests/P0323R12_expected/test.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"deque",
"exception",
"execution",
"expected",
"filesystem",
"format",
"forward_list",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import <coroutine>;
import <deque>;
import <exception>;
import <execution>;
import <expected>;
miscco marked this conversation as resolved.
Show resolved Hide resolved
import <filesystem>;
import <format>;
import <forward_list>;
Expand Down Expand Up @@ -291,6 +292,12 @@ int main() {
assert(count(execution::par, begin(arr), end(arr), 0) == 4);
}

{
puts("Testing <expected>.");
constexpr expected<double, int> test{unexpect, 42};
assert(test.error() == 42);
}

{
puts("Testing <filesystem>.");
constexpr wstring_view dot{L"."};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down