Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-01-29 01:33:02


 JOAQUIN LOPEZ MU?Z wrote

> >[...] so why not rely on some traits class and let the user state
> > what he/she prefers.
> >
> > // by default considered equal if they share their value
> > template <typename T>
> > struct flyweight_equals_if_shared_value : boost::mpl::true_{};
> >
> > // resort to the underlying values.
> > template <>
> > struct flyweight_equals_if_shared_value<istring> :
> > boost::mpl::false_{};
> > Can this be used to solve the equality semantic problems?
>
> Yep, this is a variant of another reviewer's proposal of
> having this bit of info as an extra template parameter. Either
> way is realizable. What I'm not so sure, after discussing the
> issue with you, is if we really should worry about this
> rather pathological situation: after all, if a user ever
> faces it, she just can override oeprator== with non-& semantics
> and be done.

I think that the problem is related to the underlying type on
the context of a flyweight. This approach do not needs to pass
an extra parameter each time the type is used as a flyweight.

Any way is up to you to decide whether your library takes this
cases in account or not. If you decide to not manage these
pathological cases, un example will help the user to understand
the problem.

Regards
_______________________________________________
Vicente Juan Botet Escriba


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