Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2012-02-07 16:36:56


Sorry for not coming back quicker. I've been sick.

I did some experimenting in my own codebase with a "array_vector" which acts
like vector constructs things when they're added, but like boost::array uses
a fixed size array.

I tested the techniques I would use to improve optional. So I think I can
deliver this very small set of goals cleanly:

1) ~optional doesn't set m_initialized.

2) has_trivial_destructor<T> implies has_trivial_destructor<optional<T> >

3) has_has_trivial_copy<T> and has_trivial_assign<T> implies them optional
        unless sizeof(T) exceeds some constant max_trivial_copy_Size, which
        can also be overridden.

4) I'll define a optional_traits<T> with defaults and an
        optional_with_traits<T,Traits=optional_traits<T> >
which can be used to make optionals which override features and from which
optional<T> will derive. That's the best compromise if I can't change
the signature of optional (Is Robert Stewart right?). I think we should use
the traits technique for any new libraries.

Thanks Sebastian Redl and Domagoj Saric for pointing out that (2) and (3)
will may help some compilers put cheap optionals in registers.

Shall I continue? Should I make branch or do it in trunk?

Chris


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