[SDL] Off-Topic: Quake II Ported to HTML5
Jonathan Dearborn
grimfang4 at gmail.com
Fri Apr 9 01:15:32 PDT 2010
On Thu, Apr 8, 2010 at 10:30 PM, Rainer Deyke <rainerd at eldwood.com> wrote:
>
> >> template<class T0, class T1>
> >> typeof(true ? T0() : T1()) max(T0 v0, T1 v1) {
> >> return v0 > v1 ? v0 : v1;
> >> }
> >
> - Its return type has the following properties:
> - If both arguments use integer types, the larger integer type is
> used as return type.
> - If both arguments use floating point types, the larger floating
> point type is used as return type.
> - If one argument uses a floating point type and the other uses an
> integer type, the floating point type is used as return type.
>
> The C++ version is hideously ugly, but at least it does the job.
>
>
How does it do the job of selecting the return type? I haven't seen
'typeof(true ? T0() : T1())' before and it does not look like it functions
correctly (i.e. it smells). Which implementation of typeof are you using?
This makes more sense to me, though it forces another operator overload (+)
for objects:
template<class T0, class T1>
auto max(T0 v0, T1 v1) -> typeof(v0 + v1);
Jonny D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20100409/bf47e0c4/attachment.htm>
More information about the SDL
mailing list