Removed boost::exception::what, to avoid ambiguity in user types deriving from both std::exception and boost::exception.

[SVN r46930]
This commit is contained in:
Emil Dotchevski
2008-06-30 19:40:44 +00:00
parent ad1ef37b81
commit d0febca84b
12 changed files with 1492 additions and 1819 deletions

View File

@ -77,7 +77,6 @@ boost
public: public:
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span> <span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span>
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</span>
protected: protected:
@ -167,7 +166,6 @@ boost
public: public:
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span> <span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span>
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</span>
protected: protected:
@ -202,14 +200,6 @@ boost
<p>Nothing.</p> <p>Nothing.</p>
<h4>Note:</h4> <h4>Note:</h4>
<p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p> <p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p>
</div><div class="RenoIncludeDIV"><h3>exception::what</h3>
<div class="RenoIncludeDIV"><pre>virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</pre>
</div><h4>Returns:</h4>
<p>The default implementation is equivalent to return <span class="RenoLink"><a href="exception_diagnostic_information.html">exception::diagnostic_information</a></span>(). The signature of boost::<span class="RenoLink"><a href="exception_what.html">exception::what</a></span> is identical to the familiar std::exception::what function, so that when an exception type that derives both std::exception and boost::<span class="RenoLink"><a href="exception.html">exception</a></span> overrides the what function, it overrides both std::exception::what and boost::<span class="RenoLink"><a href="exception_what.html">exception::what</a></span>.</p>
<h4>Throws:</h4>
<p>Nothing.</p>
<h4>Note:</h4>
<p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p>
</div></div><h2>Transporting of Arbitrary Data to the Catch Site</h2> </div></div><h2>Transporting of Arbitrary Data to the Catch Site</h2>
<div class="RenoIncludeDIV"><h3>error_info</h3> <div class="RenoIncludeDIV"><h3>error_info</h3>
<div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>&gt;</p> <div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>&gt;</p>

View File

@ -30,7 +30,6 @@ boost
public: public:
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span> <span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span>
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</span>
protected: protected:
@ -65,14 +64,6 @@ boost
<p>Nothing.</p> <p>Nothing.</p>
<h4>Note:</h4> <h4>Note:</h4>
<p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p> <p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p>
</div><div class="RenoIncludeDIV"><h3>exception::what</h3>
<div class="RenoIncludeDIV"><pre>virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</pre>
</div><h4>Returns:</h4>
<p>The default implementation is equivalent to return <span class="RenoLink"><a href="exception_diagnostic_information.html">exception::diagnostic_information</a></span>(). The signature of boost::<span class="RenoLink"><a href="exception_what.html">exception::what</a></span> is identical to the familiar std::exception::what function, so that when an exception type that derives both std::exception and boost::<span class="RenoLink"><a href="exception.html">exception</a></span> overrides the what function, it overrides both std::exception::what and boost::<span class="RenoLink"><a href="exception_what.html">exception::what</a></span>.</p>
<h4>Throws:</h4>
<p>Nothing.</p>
<h4>Note:</h4>
<p>The return value remains valid until the exception object from which it is obtained is destroyed or modified.</p>
</div></div><h3>See also:</h3> </div></div><h3>See also:</h3>
<div class="RenoPageList"><a href="BOOST_ERROR_INFO.html">BOOST_ERROR_INFO<br/> <div class="RenoPageList"><a href="BOOST_ERROR_INFO.html">BOOST_ERROR_INFO<br/>
</a><a href="boost-exception.html">Boost Exception<br/> </a><a href="boost-exception.html">Boost Exception<br/>

View File

@ -30,7 +30,6 @@
</div><h3>See also:</h3> </div><h3>See also:</h3>
<div class="RenoPageList"><a href="diagnostic_information.html">diagnostic_information<br/> <div class="RenoPageList"><a href="diagnostic_information.html">diagnostic_information<br/>
</a><a href="exception.html">exception<br/> </a><a href="exception.html">exception<br/>
</a><a href="exception_what.html">exception::what<br/>
</a><a href="tutorial_diagnostic_information.html">Tutorial: Diagnostic Information<br/> </a><a href="tutorial_diagnostic_information.html">Tutorial: Diagnostic Information<br/>
</a></div> </a></div>
<!-- Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. --> <!-- Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. -->

View File

@ -30,7 +30,6 @@ boost
public: public:
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span> <span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_diagnostic_information.html">diagnostic_information</a></span>() const throw();</span>
<span class="RenoIncludeSPAN"> virtual char const * <span class="RenoLink"><a href="exception_what.html">what</a></span>() const throw();</span>
protected: protected:

View File

@ -45,7 +45,6 @@
<p><a href="exception.html">exception</a></p> <p><a href="exception.html">exception</a></p>
<p><a href="exception_diagnostic_information.html">exception::diagnostic_information</a></p> <p><a href="exception_diagnostic_information.html">exception::diagnostic_information</a></p>
<p><a href="exception_constructors.html">exception::exception</a></p> <p><a href="exception_constructors.html">exception::exception</a></p>
<p><a href="exception_what.html">exception::what</a></p>
<p><a href="exception_destructor.html">exception::~exception</a></p> <p><a href="exception_destructor.html">exception::~exception</a></p>
<p><a href="exception_ptr.html">exception_ptr</a></p> <p><a href="exception_ptr.html">exception_ptr</a></p>
<h3>g</h3> <h3>g</h3>

File diff suppressed because it is too large Load Diff

View File

@ -33,12 +33,6 @@ boost
{ {
} }
char const *
what() const throw()
{
return T::what();
}
char const * char const *
diagnostic_information() const throw() diagnostic_information() const throw()
{ {

View File

@ -47,13 +47,6 @@ boost
{ {
public: public:
virtual
char const *
what() const throw()
{
return diagnostic_information();
}
virtual virtual
char const * char const *
diagnostic_information() const throw() diagnostic_information() const throw()

View File

@ -29,7 +29,6 @@ run throw_exception_test.cpp helper2.cpp ;
run errno_test.cpp ; run errno_test.cpp ;
run error_info_test.cpp ; run error_info_test.cpp ;
run diagnostic_information_test.cpp ; run diagnostic_information_test.cpp ;
run what_test.cpp ;
compile-fail exception_fail.cpp ; compile-fail exception_fail.cpp ;
compile-fail throw_exception_fail.cpp ; compile-fail throw_exception_fail.cpp ;

View File

@ -44,26 +44,20 @@ get_diagnostic_information( std::exception const & x )
return boost::diagnostic_information(x); return boost::diagnostic_information(x);
} }
std::string
get_what( std::exception const & x )
{
return x.what();
}
int int
main() main()
{ {
using namespace boost; using namespace boost;
{ {
error1 x; error1 x;
BOOST_TEST(get_what(x)=="error1"); BOOST_TEST(x.what()==std::string("error1"));
std::string di=get_diagnostic_information(x); std::string di=get_diagnostic_information(x);
BOOST_TEST(di.find("type:")!=std::string::npos); BOOST_TEST(di.find("type:")!=std::string::npos);
BOOST_TEST(di.find("error1")!=std::string::npos); BOOST_TEST(di.find("error1")!=std::string::npos);
} }
{ {
error2 x; x << tag_int(42); error2 x; x << tag_int(42);
BOOST_TEST(get_what(x)=="error2"); BOOST_TEST(x.what()==std::string("error2"));
std::string di=get_diagnostic_information(x); std::string di=get_diagnostic_information(x);
BOOST_TEST(di.find("type:")!=std::string::npos); BOOST_TEST(di.find("type:")!=std::string::npos);
BOOST_TEST(di.find("error2")!=std::string::npos); BOOST_TEST(di.find("error2")!=std::string::npos);

View File

@ -46,7 +46,6 @@ main()
{ {
BOOST_TEST( 42==*boost::get_error_info<test_int>(x) ); BOOST_TEST( 42==*boost::get_error_info<test_int>(x) );
BOOST_TEST( std::string(x.what())==std::string("exception test length error") ); BOOST_TEST( std::string(x.what())==std::string("exception test length error") );
BOOST_TEST( std::string(x.what())!=std::string(boost::diagnostic_information(x)) );
} }
catch( catch(
... ) ... )

View File

@ -1,32 +0,0 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/exception/exception.hpp>
#include <exception>
#include <string>
#include <boost/detail/lightweight_test.hpp>
struct
test_exception:
std::exception,
boost::exception
{
char const *
what() const throw()
{
return "test_exception";
}
};
int
main()
{
test_exception x;
std::exception & sx(x);
boost::exception & bx(x);
BOOST_TEST(std::string(sx.what())=="test_exception");
BOOST_TEST(std::string(bx.what())=="test_exception");
return boost::report_errors();
}