Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: Andrew Sutton (asutton.list_at_[hidden])
Date: 2010-09-28 12:08:22

> Just to show the subtletly of using valid expressions, the p(*f)
> constraint (with or without a conversion on the outside) would not allow the
> following:
> struct p {
> template <typename T>
> bool operator()(T) const { /* Something invalid */ }
> bool operator()(bool) const {return true;}
> };
> vector<bool> v;
> find_if(v.begin(), v.end(), p());

Ah... this is a good example for demonstrating subtlety. It's not entirely
obvious whether this demonstrates a flaw in or motivates a solution to any
particular approach to concepts. This seems to be the programmer's error --
they have failed to understand something very important about vector<bool>.

I suppose this discussion ultimately goes down the road of "do you just tell
the programmer why it fails, or do you try to match the programmer's
intent". Given that the compiler already does the wrong thing (in a usually
sane way), failure is good enough for me :)

Out of curiosity, what would the pseudo-signature solution look like?

Andrew Sutton

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