C++Now! 2012 slides
Peter Alexander
peter.alexander.au at gmail.com
Thu Jun 7 11:34:44 PDT 2012
On Thursday, 7 June 2012 at 16:05:00 UTC, bearophile wrote:
> "Now What?" by Sean Parent (Adobe).
I very much liked that presentation. It's nice to see someone
looking at C++ in the big picture.
I also liked his comment on the "beauty" of std::pair
"Complete std::pair 372 Lines"
D suffers from this too. Here is std.algorithm.min (ignoring the
definitions of CommonType, mostNegative, and isIntegral).
template MinType(T...)
{
static assert(T.length >= 2);
static if (T.length == 2)
{
static if (!is(typeof(T[0].min)))
alias CommonType!(T[0 .. 2]) MinType;
else static if (mostNegative!(T[1]) < mostNegative!(T[0]))
alias T[1] MinType;
else static if (mostNegative!(T[1]) > mostNegative!(T[0]))
alias T[0] MinType;
else static if (T[1].max < T[0].max)
alias T[1] MinType;
else
alias T[0] MinType;
}
else
{
alias MinType!(MinType!(T[0 .. 2]), T[2 .. $]) MinType;
}
}
MinType!(T1, T2, T) min(T1, T2, T...)(T1 a, T2 b, T xs)
{
static if (T.length == 0)
{
static if (isIntegral!(T1) && isIntegral!(T2)
&& (mostNegative!(T1) < 0) !=
(mostNegative!(T2) < 0))
static if (mostNegative!(T1) < 0)
immutable chooseB = b < a && a > 0;
else
immutable chooseB = b < a || b < 0;
else
immutable chooseB = b < a;
return cast(typeof(return)) (chooseB ? b : a);
}
else
{
return min(min(a, b), xs);
}
}
I find this very ugly. To be honest, I would be much happier
without all that mostNegative and common type stuff. If I want to
get the min between a short and an int I'll just cast them
appropriately. I'd much rather have a simpler standard library
than a complicated one for the sake of a little convenience.
Don't get me started on std.algorithm.find...
> The same question is valid for D. It seems important.
It is. D addresses vectorization a little with its array ops
(although ISPC (http://ispc.github.com/) destroys both D and C++
in this arena) and we're yet to see if D provides scalable
parallelism.
More information about the Digitalmars-d
mailing list