Boost logo

Boost Users :

Subject: Re: [Boost-users] [Exception] How do I inherit custom exception hierarchy from std::runtime_error rather than from std::exception?
From: Egor Tensin (egor.tensin_at_[hidden])
Date: 2013-11-29 11:37:06


Oh, ok, I think I got this! Thank you very much for your help.

On Fri, Nov 29, 2013 at 3:23 AM, Emil Dotchevski
<emildotchevski_at_[hidden]> wrote:
> On Thu, Nov 28, 2013 at 3:29 AM, Egor Tensin <egor.tensin_at_[hidden]> wrote:
>> Steven,
>>
>> Could you please specify, you meant the error_info_injector class
>> inside the Boost.Exception? I'm just trying to get this straight in my
>> head. Or maybe you don't know what class exactly derives from the
>> class passed as the parameter?
>
> Allow me -- calling boost::throw_exception throws an internal type
> that derives from the type of the passed object. As in the example
> below, that internal type's constructor initializes the virtual bases
> of the object, but it doesn't know about the virtual bases of the
> object -- so they get initialized by their *default* constructor.
>
> #include <iostream>
> struct a
> {
> int v;
> a(int v): v(v) { }
> };
> struct b: virtual a
> {
> b(): a(1) { }
> };
> struct c: b
> {
> c(): a(2) { }
> };
> int main()
> {
> c x; std::cout << x.v; //prints "2"
> return 0;
> }
>
> --
> Emil Dotchevski
> Reverge Studios, Inc.
> http://www.revergestudios.com/reblog/index.php?n=ReCode
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net