Subject: Re: [boost] Best method of checking for ==, <, streamability
From: joel falcou (joel.falcou_at_[hidden])
Date: 2010-11-01 13:21:53
On 01/11/10 18:15, Christopher Jefferson wrote:
> A user recently posted on boost-users asking for operator== support in boost::any. I have added this support to my private version, which extends spirit's implementation of any. I am interested in cleaning this up and submitting it to replace boost::any, if everyone is happy with this.
> The major issue is that my implementation requires type support operator==, operator< , hash and operator<< / operator>>. Are there any techniques in boost for detecting the presence of these operators which are sufficiently reliable they could be used in boost::any?
> Apologises for this question, but I have lost track of how well such checks can be implemented.
> Christopher Jefferson
It can be doen using the sizeof trick by trying to take the size of a
return type of an overloaded function depending on the very existence of
IIRC, such stuff where done for arithmetic tests and proposed for
inclusion into type_traits. You can aslo see hwo to do them here:
This is the usual way to check for memebr function. Same applies to
regular functions by changing the type of the pointer
you want to take and how to test them.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk