Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2011-09-26 10:51:20

Olaf van der Spek wrote:
> Christian Holmquist wrote:
> > enum A{a};
> > enum B(b);
> > main()
> > {
> > clamp(0, a, b);
> > }
> >
> Right.
> g++ 4.6: warning: enumeral mismatch in conditional expression: 'A' vs 'B'
> Is this really the fault of clamp() though?
> The same 'mistake' can easily be made in normal code.

The original C had a weaker type system than what is offered by the template system in C++. Because of backwards compatibility with C, many of the issues caused by this weaker type system had to stay around in C++. But this shouldn't be used as an argument in favor of duplicating such issues in template based code were they could easily be avoided.


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