@@ -10,6 +10,7 @@ int main()
1010}
1111#else
1212
13+ #include < cassert>
1314#include < exception>
1415#include < stdexcept>
1516#include < string>
@@ -37,6 +38,7 @@ namespace
3738 template < typename Processor, typename Visitor >
3839 static void rethrow ( const std::exception_ptr& caught, Visitor&& /* unused*/ , const std::size_t /* unused*/ )
3940 {
41+ assert ( caught );
4042 std::rethrow_exception ( caught ); // For the first/outer exception when supplied as exception pointer.
4143 }
4244 };
@@ -76,6 +78,7 @@ namespace
7678 template < typename Visitor >
7779 static void inspect ( const std::exception_ptr& ptr, Visitor&& visitor )
7880 {
81+ assert ( ptr );
7982 Rethrower::template rethrow< Processor >( ptr, visitor, 0 );
8083 }
8184
@@ -97,6 +100,7 @@ namespace
97100 template < typename ... Exceptions, typename Visitor >
98101 void inspect ( const std::exception_ptr& ptr, Visitor&& visitor )
99102 {
103+ assert ( ptr );
100104 internal::inspector< Exceptions... >::inspect ( ptr, visitor );
101105 }
102106
@@ -113,15 +117,15 @@ int main()
113117{
114118 try {
115119 try {
116- throw std::string ( s1 );
120+ throw std::logic_error ( s1 );
117121 }
118122 catch ( ... ) {
119123 std::throw_with_nested ( std::runtime_error ( s2 ) );
120124 }
121125 }
122126 catch ( ... ) {
123127 visitor v;
124- inspect< std::string , std::runtime_error >( v );
128+ inspect< std::logic_error , std::runtime_error >( v );
125129 }
126130 return 0 ;
127131}
0 commit comments