@@ -322,43 +322,93 @@ static int s_VariantWithNoDefaultConstructibleUnderlyingType(struct aws_allocato
322
322
323
323
AWS_TEST_CASE (VariantWithNoDefaultConstructibleUnderlyingType, s_VariantWithNoDefaultConstructibleUnderlyingType)
324
324
325
- static int s_VariantNothrowConstructible (struct aws_allocator *allocator, void *ctx)
325
+ static int s_VariantExceptionSafety_DefaultConstructor (struct aws_allocator *allocator, void *ctx)
326
326
{
327
327
(void )ctx;
328
328
329
329
Aws::Crt::ApiHandle apiHandle (allocator);
330
330
331
- struct NothrowConstructibleTestType
331
+ struct NothrowDefaultConstructibleTestType
332
332
{
333
- NothrowConstructibleTestType () noexcept = default ;
333
+ NothrowDefaultConstructibleTestType () noexcept = default ;
334
+ NothrowDefaultConstructibleTestType (const NothrowDefaultConstructibleTestType &) noexcept (false ) = default ;
335
+ NothrowDefaultConstructibleTestType (NothrowDefaultConstructibleTestType &&) noexcept (false ) = default ;
334
336
};
335
- using NothrowConstructibleVariant = Aws::Crt::Variant<NothrowConstructibleTestType>;
336
- ASSERT_TRUE (std::is_nothrow_constructible<NothrowConstructibleVariant>::value);
337
+
338
+ using NothrowDefaultConstructibleVariant = Aws::Crt::Variant<NothrowDefaultConstructibleTestType>;
339
+
340
+ ASSERT_TRUE (std::is_nothrow_constructible<NothrowDefaultConstructibleVariant>::value);
341
+ ASSERT_FALSE ((
342
+ std::is_nothrow_constructible<NothrowDefaultConstructibleVariant, const NothrowDefaultConstructibleTestType &>::
343
+ value));
344
+ ASSERT_FALSE (
345
+ (std::is_nothrow_constructible<NothrowDefaultConstructibleVariant, NothrowDefaultConstructibleTestType &&>::
346
+ value));
337
347
338
348
return AWS_OP_SUCCESS;
339
349
}
340
350
341
- AWS_TEST_CASE (VariantNothrowConstructible, s_VariantNothrowConstructible )
351
+ AWS_TEST_CASE (VariantExceptionSafety_DefaultConstructor, s_VariantExceptionSafety_DefaultConstructor )
342
352
343
- static int s_VariantThrowConstructible (struct aws_allocator *allocator, void *ctx)
353
+ static int s_VariantExceptionSafety_MoveConstructor (struct aws_allocator *allocator, void *ctx)
344
354
{
345
355
(void )ctx;
346
356
347
357
Aws::Crt::ApiHandle apiHandle (allocator);
348
358
349
- struct ThrowConstructibleTestType
359
+ struct NothrowMoveConstructibleTestType
350
360
{
351
- // Must be user-defined to be non-nothrow.
352
- ThrowConstructibleTestType () {}
361
+ NothrowMoveConstructibleTestType (NothrowMoveConstructibleTestType &&) noexcept = default ;
362
+
363
+ NothrowMoveConstructibleTestType () noexcept (false ) = default ;
364
+ NothrowMoveConstructibleTestType (const NothrowMoveConstructibleTestType &) noexcept (false ) = default ;
353
365
};
354
366
355
- using ThrowConstructibleVariant = Aws::Crt::Variant<ThrowConstructibleTestType>;
356
- ASSERT_FALSE (std::is_nothrow_constructible<ThrowConstructibleVariant>::value);
367
+ using NothrowMoveConstructibleVariant = Aws::Crt::Variant<NothrowMoveConstructibleTestType>;
368
+
369
+ ASSERT_TRUE (
370
+ (std::is_nothrow_constructible<NothrowMoveConstructibleVariant, NothrowMoveConstructibleTestType &&>::value));
371
+ ASSERT_FALSE (std::is_nothrow_constructible<NothrowMoveConstructibleVariant>::value);
372
+ ASSERT_FALSE (
373
+ (std::is_nothrow_constructible<NothrowMoveConstructibleVariant, const NothrowMoveConstructibleTestType &>::
374
+ value));
375
+
376
+ return AWS_OP_SUCCESS;
377
+ }
378
+
379
+ AWS_TEST_CASE (VariantExceptionSafety_MoveConstructor, s_VariantExceptionSafety_MoveConstructor)
380
+
381
+ static int s_VariantExceptionSafety_CopyConstructor(struct aws_allocator *allocator, void *ctx)
382
+ {
383
+ (void )ctx;
384
+
385
+ Aws::Crt::ApiHandle apiHandle (allocator);
386
+
387
+ struct NothrowCopyConstructibleTestType
388
+ {
389
+ NothrowCopyConstructibleTestType (const NothrowCopyConstructibleTestType &) noexcept = default ;
390
+
391
+ NothrowCopyConstructibleTestType () noexcept (false ) = default ;
392
+ NothrowCopyConstructibleTestType (NothrowCopyConstructibleTestType &&) noexcept (false ) = default ;
393
+
394
+ NothrowCopyConstructibleTestType &operator =(const NothrowCopyConstructibleTestType &) = default ;
395
+ NothrowCopyConstructibleTestType &operator =(NothrowCopyConstructibleTestType &&) = default ;
396
+ };
397
+
398
+ using NothrowCopyConstructibleVariant = Aws::Crt::Variant<NothrowCopyConstructibleTestType>;
399
+
400
+ ASSERT_TRUE (
401
+ (std::is_nothrow_constructible<NothrowCopyConstructibleVariant, const NothrowCopyConstructibleTestType &>::
402
+ value));
403
+
404
+ ASSERT_FALSE (std::is_nothrow_constructible<NothrowCopyConstructibleVariant>::value);
405
+ ASSERT_FALSE (
406
+ (std::is_nothrow_constructible<NothrowCopyConstructibleVariant, NothrowCopyConstructibleTestType &&>::value));
357
407
358
408
return AWS_OP_SUCCESS;
359
409
}
360
410
361
- AWS_TEST_CASE (VariantThrowConstructible, s_VariantThrowConstructible )
411
+ AWS_TEST_CASE (VariantExceptionSafety_CopyConstructor, s_VariantExceptionSafety_CopyConstructor )
362
412
363
413
struct TestStringOnlyVisitor
364
414
{
0 commit comments