Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-08-30 13:15:06


David Abrahams wrote:
> "Dirk Schreib" <Dirk.Schreib_at_[hidden]> writes:
>
>> I would like a variant to be LessThanComparable if all
>> BoundedTypes are LessThanComparable.
>>
>> In this example
>>
>> typedef boost::variant<T1, T2, ..., TN> V;
>> V v1 = T1( x );
>> V v2 = T2( y );
>> V v3 = T1( z );
>>
>> v1 < v2 should always be true. And v1 < v3 should be the same as T1(
>> x ) < T1( z ).
>>
>> I assume that the resulting variant class will be
>> StrictWeaklyComparable if all
>> BoundedTypes are StrictWeaklyComparable.
>
> Sounds like maybe you want dynamic_any. Have you looked at Alexander
> Nasonov's work?

Actually operator< makes more sense (or at least the implementation does not
pose significant problems) for variant as it is a function template (not
instantiated unless used). It is possible (but somewhat tedious) to write
this operator< using the public interface (which() and get<>()). I think
that it should be provided.


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