mirror of
https://github.com/TartanLlama/optional.git
synced 2025-06-25 00:51:37 +02:00
Merge pull request #53 from Tindarid/master
Remove `noexcept` specifier for `construct()`
This commit is contained in:
@ -409,7 +409,7 @@ template <class T> struct optional_operations_base : optional_storage_base<T> {
|
||||
this->m_has_value = false;
|
||||
}
|
||||
|
||||
template <class... Args> void construct(Args &&... args) noexcept {
|
||||
template <class... Args> void construct(Args &&... args) {
|
||||
new (std::addressof(this->m_value)) T(std::forward<Args>(args)...);
|
||||
this->m_has_value = true;
|
||||
}
|
||||
|
@ -11,3 +11,14 @@ TEST_CASE("Emplace", "[emplace]") {
|
||||
REQUIRE(i->second.first == 3);
|
||||
REQUIRE(i->second.second == 4);
|
||||
}
|
||||
|
||||
struct A {
|
||||
A() {
|
||||
throw std::exception();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("Emplace with exception thrown", "[emplace]") {
|
||||
tl::optional<A> a;
|
||||
REQUIRE_THROWS(a.emplace());
|
||||
}
|
||||
|
Reference in New Issue
Block a user