9 ms·
C++ 11 Approved
- t413 15y agoFor those who are curious: http://en.wikipedia.org/wiki/C%2B%2B0x http://en.wikipedia.org/wiki/C%2B%2B0x Huge page though, needs a tl;dr of changes.
- deleted 15y ago[deleted]
- Animus7 15y agoAwesome! 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.
- cageface 15y agoDon't forget the auto keyword. The question is, how long before I can actually use this stuff?
- Animus7 15y agoauto 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 http://gcc.gnu.org/projects/cxx0x.html
- AshleysBrain 15y agoVisual 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.
- seabee 15y agoOr maybe the next service pack. Thinking of VS2008 feature pack/SP1 which added TR1.
- sorbits 15y agoAnd status for clang: http://clang.llvm.org/cxx_status.html http://clang.llvm.org/cxx_status.html
- exDM69 15y agoWith 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.
- abrahamsen 15y agoNo love for the low level concurrency support?
- exDM69 15y agoYeah, threads, clocks and atomics are missing from this list.
- vog 15y ago> 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?
- exDM69 15y agoIt'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.
- xilun0 15y agonot e.g. with 64-bits, va args and literal 0 (cf FrankBooth example)
- biot 15y agoYou 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.
- FrankBooth 15y agoConsider: int execl(const char *path, const char *arg, ...); called like so: execl("foo", "bar", 0); Particularly when sizeof(int) != sizeof(void *).
- doug363 15y agoIn overloaded or argument-deduced contexts, then "0" is preferentially an int, but nullptr is never an int.
- Someone 15y agoThe 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.
- palish 15y agoRNG's... Did they include Mersenne Twister? http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html 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.
- archangel_one 15y agoYes - there are several options, which MT is one of: http://en.wikipedia.org/wiki/C_0x#Extensible_random_number_facility http://en.wikipedia.org/wiki/C_0x#Extensible_random_number_f...
- astrange 15y agoMersenne 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?
- corysama 15y agoDeserved 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.
- msbarnett 15y agoMy 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/e3c4ea1169e463ae http://groups.google.com/group/comp.lang.c/msg/e3c4ea1169e46... [2]: http://www.iro.umontreal.ca/~panneton/WELLRNG.html http://www.iro.umontreal.ca/~panneton/WELLRNG.html
- 15y ago
- leon_ 15y agoYeah, 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.
- shuaib 15y agoWaiting for TC++PL 4th Ed. now.
- queensnake 15y agoHeh, probably the books are ready to go, they've just been waiting for the official word. There's be new editions of all the old standards: "Yet More Effective C++", "Exceptional C++11" ... I can't wait :)
- zwieback 15y agoThat and DnE.
- 5hoom 15y agoI say this is great news. A lot of the new stuff really does make C++ both nicer to use and a good deal safer, and it will be interesting to see more boost-y style of C++ become widespread. Also glad they waited and went with C++ 11, and not C++0x which sounds like a l337 speak swearword.
- beza1e1 15y agoDie original idea was to replace the "x" with the right year. Since 2009 (C++09) didn't happen, it is C++11 now. Geeky would be hex: C++0B
- notgeekyenough 15y agoIf you wanted to write a year in hex, using the value mod 100 seems a weird way to do it. The hex year is 0x07DB, so if anything it would be C++DB. Or perhaps the first 3-4 hex digits of the Unix time would make sense - C++4E46.
- swixmix 15y agoOctal 013 would be more appropriate.
- Sharlin 15y ago0B is an invalid octal literal, to get a hex literal you'd just append B, yielding C++0xB ;)
- deleted 15y ago[deleted]
- malkia 15y agoI wonder why the C++ body does not consider things like reflection/introspection more important than the stuff they came up with. All that is needed is just an (optional, like RTTI) way to simply explain in binary format as part of the genereated binary information related to structures, types, functions, global variables, etc. For example GUI in some external format (json, xml, do not matter) that has it's signals/actions/events encoded as simple names, where at runtime you can map them to actual C++ code (Objective C has it, Java I think, .NET, etc.) This would reduce the time writing serializers, deserializers, and such. Make it optional (again like RTTI or exceptions) - but make it there for machines which can afford it (PC, Unix, OSX, and even mobile devices). Why this is important? You would find 100+ libraries trying to solve this simple problem in plethora of weird ways - such as gcc-xml, OpenC++ parser, boost, etc, etc, etc. And better preprocessor.
- pmarin 15y agoI wonder why the C++ body does not consider things like reflection/introspection more important than the stuff they came up with. The main advantage (and probably the unique) C++ has over other system languages like Objective C is the "near to C" performance and it does it maintaining the runtime at the minimum doing all his thing at compiling time. reflection/instrospection requires a more complex and slowly runtime.
- Jach 15y agoAre you saying there's no way to make it optional and, when it's not being used, maintain the same runtime speeds? Virtual functions are "costly" too, but C++ has them and it's considered poor form to not declare your destructor virtual.
- pmarin 15y agosincerely I don't know if is comparable the virtual function's overhead with the reflexion's overhead. Stroustrup answered a question about reflexion in this interview[1]: Have you ever considered adding reflection to C++? BS: Often. However, I have not seen an approach to full reflection directly supported by a language that didn't cause serious overheads. Also, reflection seems to encourage styles of programming that make it hard to determine what's going on from the source text and discourage static checking. I see that as a problem. Consequently, the C++ RTTI provides only the minimal information to determine the types of objects at run time. Where necessary, this can be used as a handle for more information about types (classes), but any such information is beyond what the standard guarantees[2]. [1] http://www2.research.att.com/~bs/omo_interview.html http://www2.research.att.com/~bs/omo_interview.html [2] I think he was talking about "type_info"
- ilitirit 15y agoWhen will we see compiler support?
- ori_b 15y agoNow -- at least for the big features, it's already implemented in GCC and Clang. I have no idea about MSVC++.
- DCoder 15y agoVC++ 2010 supports a lot of them: http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-... I've gotten into the habit of auto'ing most variables nowadays, it's quite convenient not having to type LongTemplateName<ClassName> variable = LongTemplateName<ClassName>::StaticCollection.Find(something);
- huhtenberg 15y agoSo decltype instead typeof Damn... though not really surprising. To me this exemplifies C++ - it does reasonable things, but in that slightly ass-backwards way that makes it annoying... like a light switch that is installed upside down.
- queensnake 15y agoI think it's because existing compilers (eg GCC) used typeof already for experimental implementations, so the standard had to avoid it. Same as with hashmap, hashset -> unordered_map, unordered_set.
- scott_s 15y agoYes, exactly. The natural words for things are already used as extensions, and they want to avoid clashes.