From: Stepan Palamarchuk Date: Wed, 11 Nov 2015 22:22:01 +0000 (-0800) Subject: Make Optional nothrow_default_constructible X-Git-Tag: deprecate-dynamic-initializer~260 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2cf78a6af8777724e6f4329894fcc6e7a0249a60;p=folly.git Make Optional nothrow_default_constructible Summary: It never throws. Reviewed By: pavlo-fb Differential Revision: D2640886 fb-gh-sync-id: cd643f8847f4bf5619415731484f91fb07116784 --- 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); +} + }