|
Boost : |
From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-10-01 09:54:43
Alexander Nasonov wrote:
> 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
> };
>
I'm trying to apply this technique
http://groups.google.com/groups?q=richard%40ex-parrot.com+type_fwd&hl=en&ie=ISO-8859-1&oe=ISO-8859-1&selm=1011126576.17796.0.nnrp-02.3e31d362%40news.demon.co.uk&rnum=1
but I can't. Is something wrong there?
template<class T, int>
struct type_fwd
{
typedef T type;
};
template<class T, class = T>
struct has_nothrow_destructor_helper
{
static const bool value = false;
};
template<class T>
struct has_nothrow_destructor_helper
<
T,
typename type_fwd<T, sizeof(new tester<T>) >::type
>
{
static const bool value = true;
};
-- 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