From 2cf78a6af8777724e6f4329894fcc6e7a0249a60 Mon Sep 17 00:00:00 2001 From: Stepan Palamarchuk Date: Wed, 11 Nov 2015 14:22:01 -0800 Subject: [PATCH] Make Optional nothrow_default_constructible Summary: It never throws. Reviewed By: pavlo-fb Differential Revision: D2640886 fb-gh-sync-id: cd643f8847f4bf5619415731484f91fb07116784 --- folly/Optional.h | 2 +- folly/test/OptionalTest.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/folly/Optional.h b/folly/Optional.h index def3670f..84f5d443 100644 --- a/folly/Optional.h +++ b/folly/Optional.h @@ -96,7 +96,7 @@ class Optional { static_assert(!std::is_abstract::value, "Optional may not be used with abstract types"); - Optional() + Optional() noexcept : hasValue_(false) { } diff --git a/folly/test/OptionalTest.cpp b/folly/test/OptionalTest.cpp index 42fd4926..0c3d9fdc 100644 --- a/folly/test/OptionalTest.cpp +++ b/folly/test/OptionalTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -542,4 +543,8 @@ TEST(Optional, Exceptions) { EXPECT_THROW(empty.value(), OptionalEmptyException); } +TEST(Optional, NoThrowDefaultConstructible) { + EXPECT_TRUE(std::is_nothrow_default_constructible>::value); +} + } -- 2.34.1