[libcxx] guard throw with exception enabling check

Summary: this fixes build error when built with c++14 and no exceptions

Reviewers: rmaprath

Subscribers: weimingz, grandinj, rmaprath, cfe-commits

Differential Revision: http://reviews.llvm.org/D21673

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Weiming Zhao
2016-06-24 18:02:27 +00:00
parent 3aef68f27e
commit dd421f5acd

View File

@@ -517,7 +517,11 @@ public:
constexpr value_type const& value() const
{
if (!this->__engaged_)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_optional_access();
#else
assert(!"bad optional access");
#endif
return this->__val_;
}
@@ -525,7 +529,11 @@ public:
value_type& value()
{
if (!this->__engaged_)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_optional_access();
#else
assert(!"bad optional access");
#endif
return this->__val_;
}