diff --git a/include/exception b/include/exception index cad802e05..2d8c0f541 100644 --- a/include/exception +++ b/include/exception @@ -193,6 +193,9 @@ void throw_with_nested(_Tp&& __t, typename enable_if< is_class::type>::value && !is_base_of::type>::value +#if _LIBCPP_STD_VER > 11 + && !is_final::type>::value +#endif >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< @@ -212,6 +215,9 @@ void throw_with_nested(_Tp&& __t, typename enable_if< !is_class::type>::value || is_base_of::type>::value +#if _LIBCPP_STD_VER > 11 + || is_final::type>::value +#endif >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp index 887264a5c..dad0df248 100644 --- a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -36,6 +36,10 @@ public: friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;} }; +#if __cplusplus > 201103L +struct Final final {}; +#endif + int main() { { @@ -100,4 +104,16 @@ int main() assert(i == 7); } } +#if __cplusplus > 201103L + { + try + { + std::throw_with_nested(Final()); + assert(false); + } + catch (const Final &f) + { + } + } +#endif }