Commit 7c083b08 authored by Avani Nandini's avatar Avani Nandini Committed by Sara Golemon

make move-ctor and destructor noexcept for folly::Optional

Summary:
as per summary
@override-unit-failures

Test Plan: run unit tests

Reviewed By: delong.j@fb.com

FB internal diff: D1031726
parent e14cd5e1
......@@ -91,7 +91,9 @@ class Optional {
: hasValue_(false) {
}
Optional(const Optional& src) {
Optional(const Optional& src)
noexcept(std::is_nothrow_copy_constructible<Value>::value) {
if (src.hasValue()) {
construct(src.value());
} else {
......@@ -99,7 +101,9 @@ class Optional {
}
}
Optional(Optional&& src) {
Optional(Optional&& src)
noexcept(std::is_nothrow_move_constructible<Value>::value) {
if (src.hasValue()) {
construct(std::move(src.value()));
src.clear();
......@@ -120,7 +124,7 @@ class Optional {
construct(newValue);
}
~Optional() {
~Optional() noexcept {
clear();
}
......@@ -167,12 +171,16 @@ class Optional {
return *this;
}
Optional& operator=(Optional &&other) {
Optional& operator=(Optional &&other)
noexcept (std::is_nothrow_move_assignable<Value>::value) {
assign(std::move(other));
return *this;
}
Optional& operator=(const Optional &other) {
Optional& operator=(const Optional &other)
noexcept (std::is_nothrow_copy_assignable<Value>::value) {
assign(other);
return *this;
}
......
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