@@ -1430,4 +1430,142 @@ CASE( "optional: isocpp-lib: CH 3, p0032r2 -- let's not have too clever tags" "[
1430
1430
EXPECT_NOT( **a );
1431
1431
#endif
1432
1432
}
1433
+
1434
+ #if optional_CPP11_110
1435
+ namespace issue_61 {
1436
+
1437
+ // A: copy & move constructable/assignable
1438
+ struct A
1439
+ {
1440
+ #if optional_CPP11_120
1441
+ A () = default;
1442
+ A (const A &) = default;
1443
+ A& operator =(const A &) = default ;
1444
+ A (A &&) = default;
1445
+ A& operator =(A &&) = default ;
1446
+ #else
1447
+ A () {}
1448
+ A (const A &) {}
1449
+ A& operator =(const A &) { return *this ; }
1450
+ #endif
1451
+ };
1452
+
1453
+ // B: not copy & not move constructable/assignable
1454
+
1455
+ struct B
1456
+ {
1457
+ #if optional_CPP11_120
1458
+ B () = default;
1459
+ B (const B &) = delete;
1460
+ B& operator =(const B &) = delete ;
1461
+ B (B &&) = delete;
1462
+ B& operator =(B &&) = delete ;
1463
+ #else
1464
+ B () {}
1465
+ private:
1466
+ B (const B &) {}
1467
+ B& operator =(const B &) { return *this ; }
1468
+ #endif
1469
+ };
1470
+ } // issue_61
1471
+ #endif
1472
+
1473
+ CASE ( " optional: Invalid copy/move constructible/assignable detection" " [.issue-61-print]" )
1474
+ {
1475
+ #if !optional_CPP11_110
1476
+ std::cout << " Note: Test requires C++11/VS2012 or newer, only works from VS2015.\n " ;
1477
+ #else
1478
+ using issue_61::A;
1479
+ using issue_61::B;
1480
+
1481
+ std::cout << " Copy constructible: "
1482
+ << " \n " << std::is_copy_constructible<A>::value
1483
+ << " " << std::is_copy_constructible<nonstd::optional<A>>::value
1484
+ << " \n " << std::is_copy_constructible<B>::value
1485
+ << " " << std::is_copy_constructible<nonstd::optional<B>>::value
1486
+ << std::endl;
1487
+
1488
+ std::cout << " Move constructible: "
1489
+ << " \n " << std::is_move_constructible<A>::value
1490
+ << " " << std::is_move_constructible<nonstd::optional<A>>::value
1491
+ << " \n " << std::is_move_constructible<B>::value
1492
+ << " " << std::is_move_constructible<nonstd::optional<B>>::value
1493
+ << std::endl;
1494
+
1495
+ std::cout << " Copy assignable: "
1496
+ << " \n " << std::is_copy_assignable<A>::value
1497
+ << " " << std::is_copy_assignable<nonstd::optional<A>>::value
1498
+ << " \n " << std::is_copy_assignable<B>::value
1499
+ << " " << std::is_copy_assignable<nonstd::optional<B>>::value
1500
+ << std::endl;
1501
+
1502
+ std::cout << " Move assignable: "
1503
+ << " \n " << std::is_move_assignable<A>::value
1504
+ << " " << std::is_move_assignable<nonstd::optional<A>>::value
1505
+ << " \n " << std::is_move_assignable<B>::value
1506
+ << " " << std::is_move_assignable<nonstd::optional<B>>::value
1507
+ << std::endl;
1508
+ #endif
1509
+ }
1510
+
1511
+ CASE ( " optional: Invalid copy/move constructible/assignable detection - Copy constructible" " [.issue-61-test]" )
1512
+ {
1513
+ #if optional_CPP11_140
1514
+ using issue_61::A;
1515
+ using issue_61::B;
1516
+
1517
+ EXPECT ( std::is_copy_constructible<A>::value );
1518
+ EXPECT ( std::is_copy_constructible<nonstd::optional<A>>::value );
1519
+
1520
+ EXPECT_NOT ( std::is_copy_constructible<B>::value );
1521
+ EXPECT_NOT ( std::is_copy_constructible<nonstd::optional<B>>::value );
1522
+ #else
1523
+ #endif
1524
+ }
1525
+
1526
+ CASE ( " optional: Invalid copy/move constructible/assignable detection - Move constructible" " [.issue-61-test]" )
1527
+ {
1528
+ #if optional_CPP11_140
1529
+ using issue_61::A;
1530
+ using issue_61::B;
1531
+
1532
+ EXPECT ( std::is_move_constructible<A>::value );
1533
+ EXPECT ( std::is_move_constructible<nonstd::optional<A>>::value );
1534
+
1535
+ EXPECT_NOT ( std::is_move_constructible<B>::value );
1536
+ EXPECT_NOT ( std::is_move_constructible<nonstd::optional<B>>::value );
1537
+ #else
1538
+ #endif
1539
+ }
1540
+
1541
+ CASE ( " optional: Invalid copy/move constructible/assignable detection - Copy assignable" " [.issue-61-test]" )
1542
+ {
1543
+ #if optional_CPP11_140
1544
+ using issue_61::A;
1545
+ using issue_61::B;
1546
+
1547
+ EXPECT ( std::is_copy_assignable<A>::value );
1548
+ EXPECT ( std::is_copy_assignable<nonstd::optional<A>>::value );
1549
+
1550
+ EXPECT_NOT ( std::is_copy_assignable<B>::value );
1551
+ EXPECT_NOT ( std::is_copy_assignable<nonstd::optional<B>>::value );
1552
+ #else
1553
+ #endif
1554
+ }
1555
+
1556
+ CASE ( " optional: Invalid copy/move constructible/assignable detection - Move assignable" " [.issue-61-test]" )
1557
+ {
1558
+ #if optional_CPP11_140
1559
+ using issue_61::A;
1560
+ using issue_61::B;
1561
+
1562
+ EXPECT ( std::is_move_assignable<A>::value );
1563
+ EXPECT ( std::is_move_assignable<nonstd::optional<A>>::value );
1564
+
1565
+ EXPECT_NOT ( std::is_move_assignable<B>::value );
1566
+ EXPECT_NOT ( std::is_move_assignable<nonstd::optional<B>>::value );
1567
+ #else
1568
+ #endif
1569
+ }
1570
+
1433
1571
// end of file
0 commit comments