Subject: Re: [boost] arithmetic meta functions and traits
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-12-06 03:46:02
On Sun, Dec 6, 2009 at 2:28 AM, joel falcou <joel.falcou_at_[hidden]> wrote:
> Zachary Turner wrote:
>> Is there any use for something like this? Following compiles on MSVC 9.0.
>> Despite the simplicity of the final template, it was *NOT* easy to get
>> working given that there's about 10 ways you should be able to do this
>> according to the standard, but poor SFINAE support makes it next to
>> impossible to get your compiler to accept anything. Since it doesn't do
>> anything highly fancy, I would wager it works on GCC and other compilers
>> well, although it needs to be tested.
> I think there is already something like this proposed as an extension to
> type_traits and use sizeof tricks to do that.
The sizeof trick I'm aware of is comparing the size against an "unlikely"
size N, something very large such as 43280 such that you're unlikely to come
across two types P and Q such that sizeof(P()+Q()) == N. Is there any
reason this method is preferable to the method I used above though, where it
can provably never result in a false negative?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk