@@ -390,127 +390,6 @@ TEST(OptionalTest, ImmovableEmplace) {
390390 EXPECT_EQ (0u , Immovable::Destructions);
391391}
392392
393- // Craft a class which is_trivially_copyable, but not
394- // is_trivially_copy_constructible.
395- struct NonTCopy {
396- NonTCopy () = default ;
397-
398- // Delete the volatile copy constructor to engage the "rule of 3" and delete
399- // any unspecified copy assignment or constructor.
400- NonTCopy (volatile NonTCopy const &) = delete ;
401-
402- // Leave the non-volatile default copy constructor unspecified (deleted by
403- // rule of 3)
404-
405- // This template can serve as the copy constructor, but isn't chosen
406- // by =default in a class with a 'NonTCopy' member.
407- template <typename Self = NonTCopy>
408- NonTCopy (Self const &Other) : Val(Other.Val) {}
409-
410- NonTCopy &operator =(NonTCopy const &) = default ;
411-
412- int Val{0 };
413- };
414-
415- #if defined(_MSC_VER) && _MSC_VER >= 1927
416- // Currently only true on recent MSVC releases.
417- static_assert (std::is_trivially_copyable<NonTCopy>::value,
418- " Expect NonTCopy to be trivially copyable" );
419-
420- static_assert (!std::is_trivially_copy_constructible<NonTCopy>::value,
421- " Expect NonTCopy not to be trivially copy constructible." );
422- #endif // defined(_MSC_VER) && _MSC_VER >= 1927
423-
424- TEST (OptionalTest, DeletedCopyConstructor) {
425-
426- // Expect compile to fail if 'trivial' version of
427- // optional_detail::OptionalStorage is chosen.
428- using NonTCopyOptT = Optional<NonTCopy>;
429- NonTCopyOptT NonTCopy1;
430-
431- // Check that the Optional can be copy constructed.
432- NonTCopyOptT NonTCopy2{NonTCopy1};
433-
434- // Check that the Optional can be copy assigned.
435- NonTCopy1 = NonTCopy2;
436- }
437-
438- // Craft a class which is_trivially_copyable, but not
439- // is_trivially_copy_assignable.
440- class NonTAssign {
441- public:
442- NonTAssign () = default ;
443- NonTAssign (NonTAssign const &) = default ;
444-
445- // Delete the volatile copy assignment to engage the "rule of 3" and delete
446- // any unspecified copy assignment or constructor.
447- NonTAssign &operator =(volatile NonTAssign const &) = delete ;
448-
449- // Leave the non-volatile default copy assignment unspecified (deleted by rule
450- // of 3).
451-
452- // This template can serve as the copy assignment, but isn't chosen
453- // by =default in a class with a 'NonTAssign' member.
454- template <typename Self = NonTAssign>
455- NonTAssign &operator =(Self const &Other) {
456- A = Other.A ;
457- return *this ;
458- }
459-
460- int A{0 };
461- };
462-
463- #if defined(_MSC_VER) && _MSC_VER >= 1927
464- // Currently only true on recent MSVC releases.
465- static_assert (std::is_trivially_copyable<NonTAssign>::value,
466- " Expect NonTAssign to be trivially copyable" );
467-
468- static_assert (!std::is_trivially_copy_assignable<NonTAssign>::value,
469- " Expect NonTAssign not to be trivially assignable." );
470- #endif // defined(_MSC_VER) && _MSC_VER >= 1927
471-
472- TEST (OptionalTest, DeletedCopyAssignment) {
473-
474- // Expect compile to fail if 'trivial' version of
475- // optional_detail::OptionalStorage is chosen.
476- using NonTAssignOptT = Optional<NonTAssign>;
477- NonTAssignOptT NonTAssign1;
478-
479- // Check that the Optional can be copy constructed.
480- NonTAssignOptT NonTAssign2{NonTAssign1};
481-
482- // Check that the Optional can be copy assigned.
483- NonTAssign1 = NonTAssign2;
484- }
485-
486- struct NoTMove {
487- NoTMove () = default ;
488- NoTMove (NoTMove const &) = default ;
489- NoTMove &operator =(NoTMove const &) = default ;
490-
491- // Delete move constructor / assignment. Compiler should fall-back to the
492- // trivial copy constructor / assignment in the trivial OptionalStorage
493- // specialization.
494- NoTMove (NoTMove &&) = delete ;
495- NoTMove &operator =(NoTMove &&) = delete ;
496-
497- int Val{0 };
498- };
499-
500- TEST (OptionalTest, DeletedMoveConstructor) {
501- using NoTMoveOptT = Optional<NoTMove>;
502-
503- NoTMoveOptT NonTMove1;
504- NoTMoveOptT NonTMove2{std::move (NonTMove1)};
505-
506- NonTMove1 = std::move (NonTMove2);
507-
508- static_assert (
509- std::is_trivially_copyable<NoTMoveOptT>::value,
510- " Expect Optional<NoTMove> to still use the trivial specialization "
511- " of OptionalStorage despite the deleted move constructor / assignment." );
512- }
513-
514393#if LLVM_HAS_RVALUE_REFERENCE_THIS
515394
516395TEST (OptionalTest, MoveGetValueOr) {
0 commit comments