Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2000-08-27 09:00:39


David Abrahams wrote on 8/26/2000 8:06 PM
>I wonder
>whether one can technically count on std::pair having a trivial dtor?

In general, no. Consider std::pair<std::string, int>.

John Maddock wrote on 8/27/2000 6:16 AM
>If this is a major concern and you want to be able to do compile time
>asserts and other stuff on this, then how about specialising
>boost::has_trivial_destructor etc? The principal down side is that it
>introduces a dependency (on type_traits) that you may well not want....

For completeness, this is pretty easy to do. Here's how it might look
for std::pair:

namespace boost
{

template <class T1, class T2>
struct has_trivial_destructor<std::pair<T1, T2> >
{
        static const bool value = has_trivial_destructor<T1>::value
                               && has_trivial_destructor<T2>::value;
};

}

Then you can write compile time asserts (however they are currently
spelled) to check your Cost base class(es).

-Howard


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