Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-08-23 15:39:49


>> class global_fixure {
>> public:
>> global_fixure() { pointer() = this; }
>> virtual void setup() = 0;
>> virtual void teardown() = 0;
>>
>> static global_fixure*& pointer() { static global_fixure*
>> p = 0; return
>> p; }
>>
>> protected:
>> ~global_fixure() {}
>> };
>
> Why isnt the destructor virtual? Is it because you will never have an
> instance of this class?

Because instances of global_fixure aren't supposed to be destructed through
abstract pointer. Which is reinforced by protected destructor.

> What happens if delete a_global_fixture; is called?

Nothing. Or rather it wont compile.

> [snipped some stuff]
>
> All this could be avoided if you go the route of BOOST_ASSERT in that
> you can define hooks via some free standing functions.

What could be avoided and how an alternative would look like?

Gennadiy


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