: 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 {
}
}
- Optional(Optional&& src) {
+ Optional(Optional&& src)
+ noexcept(std::is_nothrow_move_constructible<Value>::value) {
+
if (src.hasValue()) {
construct(std::move(src.value()));
src.clear();
construct(newValue);
}
- ~Optional() {
+ ~Optional() noexcept {
clear();
}
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;
}