|
Boost : |
From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-10-01 09:58:09
Alexander Nasonov wrote:
> 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?
> [snip]
SFINAE won't help, as it cannot be applied in your case. If
instantiation happens, it must succeed - no chance to get around this
AFAIK. SFINAE only works - as the name already suggests - for
substitutions, i.e. whether or not a type contains a sub-type.
Regards, Daniel
-- Daniel Frey aixigo AG - financial training, research and technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk