Boost logo

Ublas :

Subject: [ublas] Problem with "has_trivial_contructor" trait for std::complex types
From: Maharshi, Atul (atulm_at_[hidden])
Date: 2011-12-16 00:06:43


Hi,

The "has_trivial_contructor" and "has_trivial_destructor" traits as currently defined as:

        template<typename FLT>
        struct has_trivial_constructor<std::complex<FLT> > : public boost::true_type {};

        template<typename FLT>
        struct has_trivial_destructor<std::complex<FLT> > : public boost::true_type {};

This can be problematic if the FLT type has non-trivial contructor/destructor (see, for example, SystemC fixed point types - http://www.lysium.de/docs/systemc-2.2/docs/html/classsc__dt_1_1sc__fixed.html)

Perhaps, the "right" way to do define the traits is as follows:

        template<typename FLT>
        struct has_trivial_constructor<std::complex<FLT> > : public boost::has_trivial_constructor<FLT> {};

        template<typename FLT>
        struct has_trivial_destructor<std::complex<FLT> > : public boost::has_trivial_destructor<FLT> {};

I understand the C++ standard states that the "effect of instantiating the template complex for any type other than float, double or long double" is unspecified. But even for these types, one could assume that a library could use a non-trivial default constructor.

Please let me know your thoughts.

Thanks,
-Atul