Commit 2cf78a6a authored by Stepan Palamarchuk's avatar Stepan Palamarchuk Committed by facebook-github-bot-1

Make Optional nothrow_default_constructible

Summary: It never throws.

Reviewed By: pavlo-fb

Differential Revision: D2640886

fb-gh-sync-id: cd643f8847f4bf5619415731484f91fb07116784
parent 7749a469
......@@ -96,7 +96,7 @@ class Optional {
static_assert(!std::is_abstract<Value>::value,
"Optional may not be used with abstract types");
Optional()
Optional() noexcept
: hasValue_(false) {
}
......
......@@ -21,6 +21,7 @@
#include <algorithm>
#include <iomanip>
#include <string>
#include <type_traits>
#include <glog/logging.h>
#include <gtest/gtest.h>
......@@ -542,4 +543,8 @@ TEST(Optional, Exceptions) {
EXPECT_THROW(empty.value(), OptionalEmptyException);
}
TEST(Optional, NoThrowDefaultConstructible) {
EXPECT_TRUE(std::is_nothrow_default_constructible<Optional<bool>>::value);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment