Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2012-02-10 09:35:28

I think paul Fultz wrote:
> Actually, you could just take the optional_traits as the first parameter. So you define
> optional<T> or optional<optional_traits<my_traits<T> > >. Then optional would be
> specialized for optional_traits that will get the user-defined traits.

That new optional might break old code:

template<typename T>
void print(const optional<T>& o){
                T copy=*o;

That copy is going to be a optional_traits<>. My method would also force you to
add traits to the signature, but at least you wouldn't need to write two specializations:
template<typename T,typename Traits>
void print(const optional_with_traits<T, Traits >& o);

Se have to ask ourselves if configuration is worth it. I think sometimes you don't
find that out until it's too late and someone wants a option.

Things I can think of making configurable:
* bool type - a word might be faster on risk machines
* use_trivial_destruction - there might be a case for overridding this
* use_trivial_copy - cann't see a case for overriding this
* bool_first
* alignment - maybe 4 byte alignment is legal but 8 byte is faster
* enable_assertions


Boost list run by bdawes at, gregod at, cpdaniel at, john at