Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-05-07 22:22:56

Joel de Guzman <joel_at_[hidden]> writes:

> David Abrahams wrote:
>> Tobias Schwinger <tschwinger_at_[hidden]> writes:
>>> Why not make is_sequence work reliably?
>> Because it's impossible. It's always going to look for some features
>> of the type being tested that can be present even if the type is not,
>> in fact, a sequence.
> I don't see why it is impossible. MPL sequences can always
> specialize is_sequence<T>. is_sequence *can* work reliably
> 100% of the time:
> template <class S>
> struct is_sequence : mpl::false_ {}; // default
> // your specializations here

The problem isn't false negatives, it's false positives. In practice
you can probably make it vanishingly unlikely that some random
third-party type will pass all the default is_sequence tests, but you
can never make it 100% impossible as long as:

  a. sequences can be arbitrary types, such as void(int,long,char)

  b. is_sequence<S> reporting correctly is not part of the sequence

Dave Abrahams
Boost Consulting

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