News for hackers. Stuff that matters.
Re:C++ 11 Approved by Animus7 on Saturday August 13, 2011 @02:34AM (#2880456)
Awesome! I've been looking forward to the day I'm no longer relying on "experimental" C++0x support! Here's a smaller tl;dr for those who want it:

-foreach loop

-first-class rvalue ("temporary") types

-lambda functions + closures

-implicit typing (auto keyword)

-decltype(), getting "declared type" of any expression

-variadic ... templates

-expanded STL -- incl. threading and RNG's

-construction from C-style initializer list

-Unicode literals

-enum class that doesn't auto-decay to int, enums with configurable base type

-explicit strong nullptr constant; no more NULL macro nonsense

The rest of the stuff is (in my opinion) less general/noteworthy.

Re:C++ 11 Approved by palish on Saturday August 13, 2011 @06:41AM (#2880735)
RNG's... Did they include Mersenne Twister?

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

EDIT: Apologies... the only reason I asked was to contribute to the discussion, but now I realize it probably looked like I was being lazy.

Re:C++ 11 Approved by archangel_one on Saturday August 13, 2011 @06:47AM (#2880739)
Yes - there are several options, which MT is one of: http://en.wikipedia.org/wiki/C_0x#Extensible_random_number_f...
Re:C++ 11 Approved by astrange on Saturday August 13, 2011 @07:23PM (#2882275)
Mersenne Twister is hardly perfect. It's slow, causes a lot of cache misses, and IIRC the output is purely XOR of previous outputs. Do people just bring it up because they like the name?
Re:C++ 11 Approved by corysama on Sunday August 14, 2011 @01:26AM (#2882866)
Deserved or not, Mersenne Twister is somewhat famous among laymen like myself for being very fast relative to it's reasonably high quality. If you can point me at an RNG that is both faster and higher quality, I will be genuinely in your debt.
Re:C++ 11 Approved by msbarnett on Sunday August 14, 2011 @03:35AM (#2883060)
My layman's understanding is that George Marsaglia's xorshift generator[1] is considerably faster than the Mersenne Twister while still providing high quality randomness.

I've also seen WELL512[2] mentioned in a few places, but I don't know much more about it than the name.

[1]: First introduced here: http://groups.google.com/group/comp.lang.c/msg/e3c4ea1169e46...

[2]: http://www.iro.umontreal.ca/~panneton/WELLRNG.html

Re:C++ 11 Approved by corysama on Sunday August 14, 2011 @03:49AM (#2883080)
Let me know if you are ever in San Francisco and I'll open the tab at one of our many fine beer-snob bars (or a wine-snob bar, if you prefer).

This thread & invite is still open to anyone who can provide further suggestions!

Re:C++ 11 Approved by vog on Saturday August 13, 2011 @05:45AM (#2880684)
> explicit strong nullptr constant; no more NULL macro nonsense

What is the point of this? C++ defines the null pointer to be always 0. So I never needed the NULL macro in C++ anyway, as I'm allowed to simply type 0 instead.

In how far is that new nullptr constant preferable to writing simply 0?

Re:C++ 11 Approved by Someone on Saturday August 13, 2011 @09:23AM (#2880920)
The standard example is:

    void f(int x);
    void f(char *x);
    ...
    f(0);  // calls void f(int)
That may seem contrived, but you may not know of the f(int) overload, especially in combination with templates.

NULL, if #define'd as (void *)0, prevents that error.

Re:C++ 11 Approved by pmjordan on Saturday August 13, 2011 @06:03PM (#2882117)
NULL is actually #defined to 0 in C++ as void* is not implicitly convertible to any pointer type as it is in C. So unlike in C there has been no safety in using NULL. Until now.
Re:C++ 11 Approved by FrankBooth on Saturday August 13, 2011 @08:47AM (#2880859)
Consider:

  int execl(const char *path, const char *arg, ...);
called like so:

  execl("foo", "bar", 0);
Particularly when sizeof(int) != sizeof(void *).
Re:C++ 11 Approved by biot on Saturday August 13, 2011 @06:13AM (#2880711)
You may know that a null pointer is always 0, but you don't know that 0 is always a null pointer -- it may be the result of subtracting an integer from itself. That's the difference.
Re:C++ 11 Approved by doug363 on Saturday August 13, 2011 @09:00AM (#2880878)
In overloaded or argument-deduced contexts, then "0" is preferentially an int, but nullptr is never an int.
Re:C++ 11 Approved by exDM69 on Saturday August 13, 2011 @05:56AM (#2880693)
It's all about compile time warnings and static type information. The resulting code should be the same whether you're using 0, NULL or nullptr.
Re:C++ 11 Approved by xilun0 on Sunday August 14, 2011 @01:08AM (#2882848)
not e.g. with 64-bits, va args and literal 0 (cf FrankBooth example)
Re:C++ 11 Approved by cageface on Saturday August 13, 2011 @02:40AM (#2880474)
Don't forget the auto keyword.

The question is, how long before I can actually use this stuff?

Re:C++ 11 Approved by Animus7 on Saturday August 13, 2011 @02:42AM (#2880478)
auto falls under "implicit typing". Clarified this.

And we've been able to use a lot of C++0x for a while now:

http://gcc.gnu.org/projects/cxx0x.html

Re:C++ 11 Approved by AshleysBrain on Saturday August 13, 2011 @05:24AM (#2880667)
Visual Studio 2010 has about half the C++11 features (obviously it came out before the full standard was finished). Next release I guess will add more.
Re:C++ 11 Approved by seabee on Saturday August 13, 2011 @12:44PM (#2881331)
Or maybe the next service pack. Thinking of VS2008 feature pack/SP1 which added TR1.
Re:C++ 11 Approved by sorbits on Saturday August 13, 2011 @08:30AM (#2880839)
Re:C++ 11 Approved by exDM69 on Tuesday August 16, 2011 @06:18AM (#2890608)
With the C++98 standard it took almost a decade to get decent support in mainstream compilers.

This time it's different. Most of C++0x is already implemented in GCC and MSVC. However the implemented subsets are a bit different, but most of it is already there. The last time I checked, MSVC had lots of missing stuff in the standard library. In particular, threads and clocks were missing.

I've been writing C++0x with GCC for two years now.

Re:C++ 11 Approved by abrahamsen on Saturday August 13, 2011 @04:56AM (#2880643)
No love for the low level concurrency support?
Re:C++ 11 Approved by exDM69 on Saturday August 13, 2011 @05:59AM (#2880695)
Yeah, threads, clocks and atomics are missing from this list.
Re:C++ 11 Approved by leon_ on Saturday August 13, 2011 @09:00AM (#2880877)
Yeah, I'm building my subset of C++B right now. Much of the new stuff is either too complex or you will use it too rarely to make use without looking it up.