Ticket #2821: boost_exception.patch

File boost_exception.patch, 8.5 KB (added by paul.kolomiets@…, 14 years ago)

proposed fix

  • detail/error_info_impl.hpp

     
    3131            };
    3232        }
    3333
    34     template <class Tag,class T>
     34    template <class Tag,class T,class Base>
    3535    class
    3636    error_info:
    3737        public exception_detail::error_info_base
     
    3939        public:
    4040
    4141        typedef T value_type;
     42        typedef Base base_type;
    4243
    4344        error_info( value_type const & value );
    4445        ~error_info() throw();
     
    4950            return value_;
    5051            }
    5152
     53                protected:
     54                std::string value_as_string() const;
     55
    5256        private:
    53 
    5457        char const * tag_typeid_name() const;
    55         std::string value_as_string() const;
    5658
    5759        value_type const value_;
    5860        };
  • error_info.hpp

     
    33//Distributed under the Boost Software License, Version 1.0. (See accompanying
    44//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    55
    6 namespace boost { template <class Tag,class T> class error_info; }
     6namespace boost { template <class Tag,class T,class Base> class error_info; }
  • exception.hpp

     
    66#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
    77#define UUID_274DA366004E11DCB1DDFE2E56D89593
    88
     9#include <boost/exception/detail/error_info_impl.hpp>
     10
    911namespace
    1012boost
    1113    {
     
    7779
    7880    ////////////////////////////////////////////////////////////////////////
    7981
    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 <>
    8882    class
    89     error_info<tag_throw_function,char const *>
     83        throw_function:public error_info<struct tag_throw_function,char const *,throw_function>
    9084        {
    9185        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)
    9788            {
    9889            }
    9990        };
    10091
    101     template <>
    10292    class
    103     error_info<tag_throw_file,char const *>
     93        throw_file:public error_info<struct tag_throw_file,char const *,throw_file>
    10494        {
    10595        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)
    11198            {
    11299            }
    113100        };
    114101
    115     template <>
    116102    class
    117     error_info<tag_throw_line,int>
     103        throw_line:public error_info<struct tag_throw_line,int,throw_line>
    118104        {
    119105        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)
    125108            {
    126109            }
    127110        };
    128111
    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 & );
    131114
    132115    class exception;
    133116
     
    233216
    234217        friend char const * exception_detail::get_diagnostic_information( exception const & );
    235218
    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 & );
    238221
    239222        template <class>
    240223        friend struct exception_detail::get_info;
  • info.hpp

     
    1515namespace
    1616boost
    1717    {
    18     template <class Tag,class T>
     18    template <class Tag,class T,class Base>
    1919    inline
    2020    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 )
    2222        {
    2323        return to_string(x.value());
    2424        }
    2525
    26     template <class Tag,class T>
     26        template <class Tag,class T,class Base>
    2727    inline
    28     error_info<Tag,T>::
     28    error_info<Tag,T,Base>::
    2929    error_info( value_type const & value ):
    3030        value_(value)
    3131        {
    3232        }
    3333
    34     template <class Tag,class T>
     34    template <class Tag,class T,class Base>
    3535    inline
    36     error_info<Tag,T>::
     36    error_info<Tag,T,Base>::
    3737    ~error_info() throw()
    3838        {
    3939        }
    4040
    41     template <class Tag,class T>
     41    template <class Tag,class T,class Base>
    4242    inline
    4343    char const *
    44     error_info<Tag,T>::
     44    error_info<Tag,T,Base>::
    4545    tag_typeid_name() const
    4646        {
    4747        return tag_type_name<Tag>();
    4848        }
    4949
    50     template <class Tag,class T>
     50    template <class Tag,class T,class Base>
    5151    inline
    5252    std::string
    53     error_info<Tag,T>::
     53    error_info<Tag,T,Base>::
    5454    value_as_string() const
    5555        {
    5656        return to_string_stub(*this);
     
    141141            };
    142142        }
    143143
    144     template <class E,class Tag,class T>
     144    template <class E,class Tag,class T,class Base>
    145145    inline
    146146    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 )
    148148        {
    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) );
    151151        exception_detail::error_info_container * c;
    152152        if( !(c=x.data_.get()) )
    153153            x.data_.adopt(c=new exception_detail::error_info_container_impl);
    154154        c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t));
    155155        return x;
    156156        }
    157     }
    158157
     158        }
     159
    159160#endif
  • info_tuple.hpp

     
    1414    {
    1515    template <
    1616        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 >
    1919    inline
    2020    E const &
    2121    operator<<(
    2222        E const & x,
    2323        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 )
    2626        {
    2727        return x << v.template get<0>() << v.template get<1>();
    2828        }
    2929
    3030    template <
    3131        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 >
    3535    inline
    3636    E const &
    3737    operator<<(
    3838        E const & x,
    3939        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 )
    4343        {
    4444        return x << v.template get<0>() << v.template get<1>() << v.template get<2>();
    4545        }
    4646
    4747    template <
    4848        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 >
    5353    inline
    5454    E const &
    5555    operator<<(
    5656        E const & x,
    5757        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 )
    6262        {
    6363        return x << v.template get<0>() << v.template get<1>() << v.template get<2>() << v.template get<3>();
    6464        }