Boost logo

Boost Users :

From: Daryle Walker (darylew_at_[hidden])
Date: 2005-08-25 16:59:09


On 8/24/05 7:18 PM, "Gennadiy Rozental" <gennadiy.rozental_at_[hidden]>
wrote:

[SNIP]
>> In that case, why use m_space at all. Instead, just something like
>> the following (which may have stupid syntax errors):
>>
>> template<typename F>
>> class global_fixture_impl : public global_fixture {
>> virtual void setup() { m_f = new F; };
>> virtual void teardown() { delete m_f; m_f = 0; };
>> F* m_f;
>> }
>
> Yes, you right of course ;))

Maybe you could use "auto_ptr" to help (not syntax-checked either):

    template < typename F >
    class global_fixture_impl
        : public global_fixture
    {
        virtual void setup() { f.reset( new F ); }
        virtual void teardown() { f.reset(); }

        std::auto_ptr<F> f_;
    };

I'm just interrupting here, so I don't know why you're not using a
constructor & destructor pair (i.e. actual RAII) instead of virtual member
functions.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

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