Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Apr 9, 2022
1 parent 8a7b0a1 commit f1f5ff1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stl/inc/expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#define _EXPECTED_
#include <yvals.h>
#if _STL_COMPILER_PREPROCESSOR
#if !_HAS_CXX23 && defined(__cpp_lib_concepts)
#ifndef __cpp_lib_expected
#pragma message("The contents of <expected> are available only with C++23 or later.")
#else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv
#else // ^^^ !__cpp_lib_expected / __cpp_lib_expected vvv
#include <concepts>
#include <exception>
#include <initializer_list>
Expand Down Expand Up @@ -171,7 +171,7 @@ public:

// [expected.object.ctor]
// clang-format off
constexpr expected() requires is_default_constructible_v<_Ty> : _Has_value(true), _Value() {};
constexpr expected() requires is_default_constructible_v<_Ty> : _Has_value(true), _Value() {}

constexpr expected(const expected& _Other) noexcept(
is_nothrow_copy_constructible_v<_Ty>&& is_nothrow_copy_constructible_v<_Err>) //
Expand Down Expand Up @@ -324,6 +324,7 @@ public:
_STD destroy_at(_STD addressof(_Old_val));
_STD construct_at(_STD addressof(_New_val), _STD move(_Tmp));
} else {
_STL_INTERNAL_STATIC_ASSERT(is_nothrow_move_constructible_v<_Second>);
_Second _Tmp(_STD move(_Old_val));
_STD destroy_at(addressof(_Old_val));
try {
Expand Down Expand Up @@ -1015,6 +1016,6 @@ _STD_END
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _HAS_CXX23
#endif // __cpp_lib_expected
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPECTED_
Original file line number Diff line number Diff line change
Expand Up @@ -292,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

0 comments on commit f1f5ff1

Please sign in to comment.