Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-10-01 06:28:25


Hi,
I think it's possible to detect classes that have dtor with throw() spec.
The trick is based on a fact that implicitly declared dtor inherits
throw-spec from its bases and a fact that virtual dtor overrided in a
derived class can't have less restrictive throw-spec.

In this example, tester<T> can only be instantiated if T's dtor looks like
T::~T() throw(); otherwise, a compiler will complain. SFINAE can be applied
to get rid of compile error.

struct virtual_nothrow_dtor
{
    virtual ~virtual_nothrow_dtor() throw();
};

template<class T>
struct tester : T, virtual_nothrow_dtor
{
    // Implicitly defined dtor
};

-- 
Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk