mirror of
https://github.com/boostorg/exception.git
synced 2025-07-01 06:51:02 +02:00
Compare commits
17 Commits
boost-1.56
...
boost-1.62
Author | SHA1 | Date | |
---|---|---|---|
44fcc63f36 | |||
c1e2284628 | |||
3003123b2b | |||
c1dc3b8dcb | |||
dac601519d | |||
1afb7e0372 | |||
c57eefbf42 | |||
5a040eedf5 | |||
c1f6b743e4 | |||
e5e4652b75 | |||
af4de75bac | |||
38bfc39d10 | |||
5dea76a301 | |||
8931eb2e0d | |||
a129725e3e | |||
8f097eb241 | |||
7062572c8f |
@ -12,6 +12,8 @@
|
||||
#pragma warning(push,1)
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
@ -41,11 +43,16 @@ boost
|
||||
error_info:
|
||||
public exception_detail::error_info_base
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
error_info( value_type const & value );
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
error_info( error_info const & );
|
||||
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value))));
|
||||
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_))));
|
||||
#endif
|
||||
~error_info() throw();
|
||||
|
||||
value_type const &
|
||||
@ -60,7 +67,11 @@ boost
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
error_info & operator=( error_info const & );
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
error_info & operator=( error_info && x );
|
||||
#endif
|
||||
|
||||
std::string name_value_string() const;
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/exception/detail/type_info.hpp>
|
||||
#include <boost/exception/detail/clone_current_exception.hpp>
|
||||
//#ifndef BOOST_NO_RTTI
|
||||
//#include <boost/units/detail/utility.hpp>
|
||||
//#endif
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#include <boost/core/demangle.hpp>
|
||||
#endif
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
@ -92,7 +92,7 @@ boost
|
||||
std::string
|
||||
to_string( original_exception_type const & x )
|
||||
{
|
||||
return /*units::detail::demangle*/(x.value()->name());
|
||||
return core::demangle(x.value()->name());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -12,12 +12,10 @@
|
||||
#pragma warning(push,1)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
//#ifndef BOOST_NO_TYPEID
|
||||
//#include <boost/units/detail/utility.hpp>
|
||||
//#endif
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
@ -31,7 +29,7 @@ boost
|
||||
#ifdef BOOST_NO_TYPEID
|
||||
return BOOST_CURRENT_FUNCTION;
|
||||
#else
|
||||
return /*units::detail::demangle*/(typeid(T*).name());
|
||||
return core::demangle(typeid(T*).name());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -43,7 +41,7 @@ boost
|
||||
#ifdef BOOST_NO_TYPEID
|
||||
return BOOST_CURRENT_FUNCTION;
|
||||
#else
|
||||
return /*units::detail::demangle*/(typeid(T).name());
|
||||
return core::demangle(typeid(T).name());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -53,10 +51,10 @@ boost
|
||||
struct
|
||||
type_info_
|
||||
{
|
||||
detail::sp_typeinfo const * type_;
|
||||
core::typeinfo const * type_;
|
||||
|
||||
explicit
|
||||
type_info_( detail::sp_typeinfo const & type ):
|
||||
type_info_( core::typeinfo const & type ):
|
||||
type_(&type)
|
||||
{
|
||||
}
|
||||
@ -71,7 +69,7 @@ boost
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T))
|
||||
#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_CORE_TYPEID(T))
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
//#ifndef BOOST_NO_RTTI
|
||||
//#include <boost/units/detail/utility.hpp>
|
||||
//#endif
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#include <boost/core/demangle.hpp>
|
||||
#endif
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@ -151,7 +151,7 @@ boost
|
||||
#ifndef BOOST_NO_RTTI
|
||||
if ( verbose )
|
||||
tmp << std::string("Dynamic exception type: ") <<
|
||||
/*units::detail::demangle*/((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
|
||||
core::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
|
||||
#endif
|
||||
if( with_what && se && verbose )
|
||||
tmp << "std::exception::what: " << wh << '\n';
|
||||
|
@ -10,6 +10,7 @@
|
||||
#endif
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma warning(push,1)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#include "boost/exception/info.hpp"
|
||||
@ -33,7 +34,7 @@ boost
|
||||
{
|
||||
std::ostringstream tmp;
|
||||
int v=e.value();
|
||||
tmp << v << ", \"" << strerror(v) << "\"";
|
||||
tmp << '[' << error_info_name(e) << "] = " << v << ", \"" << strerror(v) << "\"\n";
|
||||
return tmp.str();
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,30 @@ boost
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
error_info<Tag,T>::
|
||||
error_info( error_info const & x ):
|
||||
value_(x.value_)
|
||||
{
|
||||
}
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
error_info<Tag,T>::
|
||||
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value)))):
|
||||
value_(std::move(value))
|
||||
{
|
||||
}
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
error_info<Tag,T>::
|
||||
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_)))):
|
||||
value_(std::move(x.value_))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
error_info<Tag,T>::
|
||||
@ -175,6 +199,85 @@ boost
|
||||
return x;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class E,class Tag,class T>
|
||||
E const & set_info( E const &, error_info<Tag,T> && );
|
||||
template <class T>
|
||||
class set_info_rv;
|
||||
template <class Tag,class T>
|
||||
class
|
||||
set_info_rv<error_info<Tag,T> >
|
||||
{
|
||||
template <class E,class Tag1,class T1>
|
||||
friend E const & set_info( E const &, error_info<Tag1,T1> && );
|
||||
template <class E>
|
||||
static
|
||||
E const &
|
||||
set( E const & x, error_info<Tag,T> && v )
|
||||
{
|
||||
typedef error_info<Tag,T> error_info_tag_t;
|
||||
shared_ptr<error_info_tag_t> p( new error_info_tag_t(std::move(v)) );
|
||||
exception_detail::error_info_container * c=x.data_.get();
|
||||
if( !c )
|
||||
x.data_.adopt(c=new exception_detail::error_info_container_impl);
|
||||
c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t));
|
||||
return x;
|
||||
}
|
||||
};
|
||||
template <>
|
||||
class
|
||||
set_info_rv<throw_function>
|
||||
{
|
||||
template <class E,class Tag1,class T1>
|
||||
friend E const & set_info( E const &, error_info<Tag1,T1> && );
|
||||
template <class E>
|
||||
static
|
||||
E const &
|
||||
set( E const & x, throw_function && y )
|
||||
{
|
||||
x.throw_function_=y.v_;
|
||||
return x;
|
||||
}
|
||||
};
|
||||
template <>
|
||||
class
|
||||
set_info_rv<throw_file>
|
||||
{
|
||||
template <class E,class Tag1,class T1>
|
||||
friend E const & set_info( E const &, error_info<Tag1,T1> && );
|
||||
template <class E>
|
||||
static
|
||||
E const &
|
||||
set( E const & x, throw_file && y )
|
||||
{
|
||||
x.throw_file_=y.v_;
|
||||
return x;
|
||||
}
|
||||
};
|
||||
template <>
|
||||
class
|
||||
set_info_rv<throw_line>
|
||||
{
|
||||
template <class E,class Tag1,class T1>
|
||||
friend E const & set_info( E const &, error_info<Tag1,T1> && );
|
||||
template <class E>
|
||||
static
|
||||
E const &
|
||||
set( E const & x, throw_line && y )
|
||||
{
|
||||
x.throw_line_=y.v_;
|
||||
return x;
|
||||
}
|
||||
};
|
||||
template <class E,class Tag,class T>
|
||||
inline
|
||||
E const &
|
||||
set_info( E const & x, error_info<Tag,T> && v )
|
||||
{
|
||||
return set_info_rv<error_info<Tag,T> >::template set<E>(x,std::move(v));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
struct
|
||||
derives_boost_exception
|
||||
@ -190,6 +293,16 @@ boost
|
||||
{
|
||||
return exception_detail::set_info(x,v);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class E,class Tag,class T>
|
||||
inline
|
||||
typename enable_if<exception_detail::derives_boost_exception<E>,E const &>::type
|
||||
operator<<( E const & x, error_info<Tag,T> && v )
|
||||
{
|
||||
return exception_detail::set_info(x,std::move(v));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
|
15
meta/libraries.json
Normal file
15
meta/libraries.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"key": "exception",
|
||||
"name": "Exception",
|
||||
"authors": [
|
||||
"Emil Dotchevski"
|
||||
],
|
||||
"description": "The Boost Exception library supports transporting of arbitrary data in exception objects, and transporting of exceptions between threads.",
|
||||
"documentation": "doc/boost-exception.html",
|
||||
"category": [
|
||||
"Emulation"
|
||||
],
|
||||
"maintainers": [
|
||||
"Emil Dotchevski <emil -at- revergestudios.com>"
|
||||
]
|
||||
}
|
@ -34,7 +34,10 @@ run exception_test.cpp ;
|
||||
run enable_error_info_test.cpp helper1.cpp ;
|
||||
run throw_exception_test.cpp helper2.cpp ;
|
||||
run errno_test.cpp ;
|
||||
run error_info_test.cpp ;
|
||||
run error_info_lv_test.cpp ;
|
||||
run error_info_lv_const_test.cpp ;
|
||||
run error_info_rv_test.cpp ;
|
||||
run error_info_rv_const_test.cpp ;
|
||||
run diagnostic_information_test.cpp ;
|
||||
run refcount_ptr_test.cpp ;
|
||||
run current_exception_cast_test.cpp ;
|
||||
|
13
test/error_info_lv_const_test.cpp
Normal file
13
test/error_info_lv_const_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//Copyright (c) 2006-2015 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/info.hpp"
|
||||
template <class E,class I>
|
||||
E const &
|
||||
add_info( E const & e, I const & i )
|
||||
{
|
||||
return e << i;
|
||||
}
|
||||
#include "error_info_test.hpp"
|
13
test/error_info_lv_test.cpp
Normal file
13
test/error_info_lv_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//Copyright (c) 2006-2015 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/info.hpp"
|
||||
template <class E,class I>
|
||||
E const &
|
||||
add_info( E const & e, I i )
|
||||
{
|
||||
return e << i;
|
||||
}
|
||||
#include "error_info_test.hpp"
|
28
test/error_info_rv_const_test.cpp
Normal file
28
test/error_info_rv_const_test.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
//Copyright (c) 2006-2015 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/info.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
int
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
template <class I>
|
||||
I const
|
||||
rv_const( I i )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
template <class E,class I>
|
||||
E const &
|
||||
add_info( E const & e, I i )
|
||||
{
|
||||
return e << rv_const(i);
|
||||
}
|
||||
#include "error_info_test.hpp"
|
||||
#endif
|
22
test/error_info_rv_test.cpp
Normal file
22
test/error_info_rv_test.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//Copyright (c) 2006-2015 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/info.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
int
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
template <class E,class I>
|
||||
E const &
|
||||
add_info( E const & e, I i )
|
||||
{
|
||||
return e << std::move(i);
|
||||
}
|
||||
#include "error_info_test.hpp"
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2015 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)
|
||||
@ -69,7 +69,7 @@ basic_test()
|
||||
try
|
||||
{
|
||||
test_exception x;
|
||||
x << test_1(1) << test_2(2u) << test_3(3.14159f);
|
||||
add_info(add_info(add_info(x,test_1(1)),test_2(2u)),test_3(3.14159f));
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
@ -86,7 +86,7 @@ basic_test()
|
||||
try
|
||||
{
|
||||
test_exception x;
|
||||
x << test_1(1) << test_2(2u) << test_3(3.14159f);
|
||||
add_info(add_info(add_info(x,test_1(1)),test_2(2u)),test_3(3.14159f));
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
@ -105,7 +105,7 @@ exception_safety_test()
|
||||
test_exception x;
|
||||
try
|
||||
{
|
||||
x << test_4(throws_on_copy());
|
||||
add_info(x,test_4(throws_on_copy()));
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
@ -124,13 +124,13 @@ throw_empty()
|
||||
void
|
||||
throw_test_1( char const * value )
|
||||
{
|
||||
throw test_exception() << test_5(std::string(value));
|
||||
throw add_info(test_exception(),test_5(std::string(value)));
|
||||
}
|
||||
|
||||
void
|
||||
throw_test_2()
|
||||
{
|
||||
throw test_exception() << test_6(non_printable());
|
||||
throw add_info(test_exception(),test_6(non_printable()));
|
||||
}
|
||||
|
||||
void
|
||||
@ -144,7 +144,7 @@ throw_catch_add_file_name( char const * name )
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
x << test_5(std::string(name));
|
||||
add_info(x,test_5(std::string(name)));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -256,10 +256,10 @@ test_add_tuple()
|
||||
typedef boost::tuple<test_1,test_2,test_3,test_5> tuple_test_1235;
|
||||
try
|
||||
{
|
||||
throw test_exception() << tuple_test_();
|
||||
throw add_info(test_exception(),tuple_test_());
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
test_exception & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
@ -269,7 +269,7 @@ test_add_tuple()
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << tuple_test_1(42);
|
||||
throw add_info(test_exception(),tuple_test_1(42));
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
@ -283,7 +283,7 @@ test_add_tuple()
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << tuple_test_12(42,42u);
|
||||
throw add_info(test_exception(),tuple_test_12(42,42u));
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
@ -298,7 +298,7 @@ test_add_tuple()
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << tuple_test_123(42,42u,42.0f);
|
||||
throw add_info(test_exception(),tuple_test_123(42,42u,42.0f));
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
@ -314,7 +314,7 @@ test_add_tuple()
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << tuple_test_1235(42,42u,42.0f,std::string("42"));
|
||||
throw add_info(test_exception(),tuple_test_1235(42,42u,42.0f,std::string("42")));
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
@ -337,7 +337,7 @@ test_lifetime1()
|
||||
int count=0;
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_7(user_data(count));
|
||||
throw add_info(test_exception(),test_7(user_data(count)));
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
@ -359,7 +359,7 @@ test_lifetime2()
|
||||
int count=0;
|
||||
{
|
||||
boost::exception_ptr ep;
|
||||
test_exception e; e<<test_7(user_data(count));
|
||||
test_exception e; add_info(e,test_7(user_data(count)));
|
||||
ep=boost::copy_exception(e);
|
||||
BOOST_TEST(count>0);
|
||||
}
|
Reference in New Issue
Block a user