are the boost ptr containers exception safe?

Discussion in 'C++' started by Peter, Dec 8, 2006.

  1. Peter

    Peter Guest

    boost::ptr_vector<animal> vec;
    vec.push_back( new animal );

    What does happen if push_back() fails -- do I have a leak?
    Peter, Dec 8, 2006
    #1
    1. Advertising

  2. Peter wrote:
    > boost::ptr_vector<animal> vec;
    > vec.push_back( new animal );
    >
    > What does happen if push_back() fails -- do I have a leak?


    Did you know that Boost has its own discussion forums?
    Victor Bazarov, Dec 8, 2006
    #2
    1. Advertising

  3. "Peter" wrote:

    > boost::ptr_vector<animal> vec;
    > vec.push_back( new animal );
    >
    > What does happen if push_back() fails -- do I have a leak?
    >


    No leak.

    All Boost libraries are designed exception safe (modulo bugs).
    /Pavel
    Pavel Vozenilek, Dec 12, 2006
    #3
  4. On Tue, 12 Dec 2006 19:19:48 +0100, "Pavel Vozenilek" wrote:
    >"Peter" wrote:
    >
    >> boost::ptr_vector<animal> vec;
    >> vec.push_back( new animal );
    >>
    >> What does happen if push_back() fails -- do I have a leak?

    >
    >No leak.
    >
    >All Boost libraries are designed exception safe (modulo bugs).


    To be more precise, wrt to exception-safety (as defined in
    http://www.boost.org/more/generic_exception_safety.html) the function
    provides the basic guarantee but not the strong guarantee.

    Best regards,
    Roland Pibinger
    Roland Pibinger, Dec 12, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sid
    Replies:
    5
    Views:
    1,071
  2. Heiko Vogel
    Replies:
    3
    Views:
    553
    Method Man
    Sep 14, 2004
  3. franco ziade

    const ptr to const ptr ?

    franco ziade, Feb 17, 2005, in forum: C Programming
    Replies:
    3
    Views:
    393
    franco ziade
    Feb 17, 2005
  4. G Fernandes
    Replies:
    9
    Views:
    589
    DHOLLINGSWORTH2
    Feb 27, 2005
  5. Jason

    difference between *ptr++ and ++*ptr ?

    Jason, May 15, 2005, in forum: C Programming
    Replies:
    19
    Views:
    6,528
    Chris Torek
    May 19, 2005
Loading...

Share This Page