Ticket #2821: boost_exception.patch
File boost_exception.patch, 8.5 KB (added by , 14 years ago) |
---|
-
detail/error_info_impl.hpp
31 31 }; 32 32 } 33 33 34 template <class Tag,class T >34 template <class Tag,class T,class Base> 35 35 class 36 36 error_info: 37 37 public exception_detail::error_info_base … … 39 39 public: 40 40 41 41 typedef T value_type; 42 typedef Base base_type; 42 43 43 44 error_info( value_type const & value ); 44 45 ~error_info() throw(); … … 49 50 return value_; 50 51 } 51 52 53 protected: 54 std::string value_as_string() const; 55 52 56 private: 53 54 57 char const * tag_typeid_name() const; 55 std::string value_as_string() const;56 58 57 59 value_type const value_; 58 60 }; -
error_info.hpp
3 3 //Distributed under the Boost Software License, Version 1.0. (See accompanying 4 4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 5 6 namespace boost { template <class Tag,class T > class error_info; }6 namespace boost { template <class Tag,class T,class Base> class error_info; } -
exception.hpp
6 6 #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 7 7 #define UUID_274DA366004E11DCB1DDFE2E56D89593 8 8 9 #include <boost/exception/detail/error_info_impl.hpp> 10 9 11 namespace 10 12 boost 11 13 { … … 77 79 78 80 //////////////////////////////////////////////////////////////////////// 79 81 80 template <class Tag,class T>81 class error_info;82 83 typedef error_info<struct tag_throw_function,char const *> throw_function;84 typedef error_info<struct tag_throw_file,char const *> throw_file;85 typedef error_info<struct tag_throw_line,int> throw_line;86 87 template <>88 82 class 89 error_info<tag_throw_function,char const *>83 throw_function:public error_info<struct tag_throw_function,char const *,throw_function> 90 84 { 91 85 public: 92 typedef char const * value_type; 93 value_type v_; 94 explicit 95 error_info( value_type v ): 96 v_(v) 86 throw_function( char const * v ): 87 error_info<tag_throw_function,char const *,throw_function> (v) 97 88 { 98 89 } 99 90 }; 100 91 101 template <>102 92 class 103 error_info<tag_throw_file,char const *>93 throw_file:public error_info<struct tag_throw_file,char const *,throw_file> 104 94 { 105 95 public: 106 typedef char const * value_type; 107 value_type v_; 108 explicit 109 error_info( value_type v ): 110 v_(v) 96 throw_file( char const * v ): 97 error_info<tag_throw_file,char const *,throw_file> (v) 111 98 { 112 99 } 113 100 }; 114 101 115 template <>116 102 class 117 error_info<tag_throw_line,int>103 throw_line:public error_info<struct tag_throw_line,int,throw_line> 118 104 { 119 105 public: 120 typedef int value_type; 121 value_type v_; 122 explicit 123 error_info( value_type v ): 124 v_(v) 106 throw_line( int v ): 107 error_info<tag_throw_line,int,throw_line> (v) 125 108 { 126 109 } 127 110 }; 128 111 129 template <class E,class Tag,class T >130 E const & operator<<( E const &, error_info<Tag,T > const & );112 template <class E,class Tag,class T,class Base> 113 E const & operator<<( E const &, error_info<Tag,T,Base> const & ); 131 114 132 115 class exception; 133 116 … … 233 216 234 217 friend char const * exception_detail::get_diagnostic_information( exception const & ); 235 218 236 template <class E,class Tag,class T >237 friend E const & operator<<( E const &, error_info<Tag,T > const & );219 template <class E,class Tag,class T,class Base> 220 friend E const & operator<<( E const &, error_info<Tag,T,Base> const & ); 238 221 239 222 template <class> 240 223 friend struct exception_detail::get_info; -
info.hpp
15 15 namespace 16 16 boost 17 17 { 18 template <class Tag,class T >18 template <class Tag,class T,class Base> 19 19 inline 20 20 typename enable_if<has_to_string<T>,std::string>::type 21 to_string( error_info<Tag,T > const & x )21 to_string( error_info<Tag,T,Base> const & x ) 22 22 { 23 23 return to_string(x.value()); 24 24 } 25 25 26 template <class Tag,class T>26 template <class Tag,class T,class Base> 27 27 inline 28 error_info<Tag,T >::28 error_info<Tag,T,Base>:: 29 29 error_info( value_type const & value ): 30 30 value_(value) 31 31 { 32 32 } 33 33 34 template <class Tag,class T >34 template <class Tag,class T,class Base> 35 35 inline 36 error_info<Tag,T >::36 error_info<Tag,T,Base>:: 37 37 ~error_info() throw() 38 38 { 39 39 } 40 40 41 template <class Tag,class T >41 template <class Tag,class T,class Base> 42 42 inline 43 43 char const * 44 error_info<Tag,T >::44 error_info<Tag,T,Base>:: 45 45 tag_typeid_name() const 46 46 { 47 47 return tag_type_name<Tag>(); 48 48 } 49 49 50 template <class Tag,class T >50 template <class Tag,class T,class Base> 51 51 inline 52 52 std::string 53 error_info<Tag,T >::53 error_info<Tag,T,Base>:: 54 54 value_as_string() const 55 55 { 56 56 return to_string_stub(*this); … … 141 141 }; 142 142 } 143 143 144 template <class E,class Tag,class T >144 template <class E,class Tag,class T,class Base> 145 145 inline 146 146 E const & 147 operator<<( E const & x, error_info<Tag,T > const & v )147 operator<<( E const & x, error_info<Tag,T,Base> const & v ) 148 148 { 149 typedef error_info<Tag,T > error_info_tag_t;150 shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) );149 typedef error_info<Tag,T,Base> error_info_tag_t; 150 shared_ptr<error_info_tag_t> p( new Base(v) ); 151 151 exception_detail::error_info_container * c; 152 152 if( !(c=x.data_.get()) ) 153 153 x.data_.adopt(c=new exception_detail::error_info_container_impl); 154 154 c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t)); 155 155 return x; 156 156 } 157 }158 157 158 } 159 159 160 #endif -
info_tuple.hpp
14 14 { 15 15 template < 16 16 class E, 17 class Tag1,class T1, 18 class Tag2,class T2 >17 class Tag1,class T1,class Base1, 18 class Tag2,class T2,class Base2 > 19 19 inline 20 20 E const & 21 21 operator<<( 22 22 E const & x, 23 23 tuple< 24 error_info<Tag1,T1 >,25 error_info<Tag2,T2 > > const & v )24 error_info<Tag1,T1,Base1>, 25 error_info<Tag2,T2,Base2> > const & v ) 26 26 { 27 27 return x << v.template get<0>() << v.template get<1>(); 28 28 } 29 29 30 30 template < 31 31 class E, 32 class Tag1,class T1, 33 class Tag2,class T2, 34 class Tag3,class T3 >32 class Tag1,class T1,class Base1, 33 class Tag2,class T2,class Base2, 34 class Tag3,class T3,class Base3 > 35 35 inline 36 36 E const & 37 37 operator<<( 38 38 E const & x, 39 39 tuple< 40 error_info<Tag1,T1 >,41 error_info<Tag2,T2 >,42 error_info<Tag3,T3 > > const & v )40 error_info<Tag1,T1,Base1>, 41 error_info<Tag2,T2,Base2>, 42 error_info<Tag3,T3,Base3> > const & v ) 43 43 { 44 44 return x << v.template get<0>() << v.template get<1>() << v.template get<2>(); 45 45 } 46 46 47 47 template < 48 48 class E, 49 class Tag1,class T1, 50 class Tag2,class T2, 51 class Tag3,class T3, 52 class Tag4,class T4 >49 class Tag1,class T1,class Base1, 50 class Tag2,class T2,class Base2, 51 class Tag3,class T3,class Base3, 52 class Tag4,class T4,class Base4 > 53 53 inline 54 54 E const & 55 55 operator<<( 56 56 E const & x, 57 57 tuple< 58 error_info<Tag1,T1 >,59 error_info<Tag2,T2 >,60 error_info<Tag3,T3 >,61 error_info<Tag4,T4 > > const & v )58 error_info<Tag1,T1,Base1>, 59 error_info<Tag2,T2,Base2>, 60 error_info<Tag3,T3,Base3>, 61 error_info<Tag4,T4,Base4> > const & v ) 62 62 { 63 63 return x << v.template get<0>() << v.template get<1>() << v.template get<2>() << v.template get<3>(); 64 64 }