5 ms·
C++ International Standard final draft is ready
- sambeau 16y agoWhile most C++ users continued with the same tiny subset of the language they have always used…
- jpr 16y agoExcept that even the C++ hello world uses most features of the language: * C-like functions (main) * headers (iostream) * namespaces (std) * operator overloading (<<) * object-orientation (cout is an instance of a class that is derived from ios and ios_base) * templates (endl is a template function)
- marshray 16y agoI don't think it's correct to characterize the C++ hello world as using object-orientation or even templates. There's no template syntax in it, for example. It does use that one predefined object std::cout and its overloaded operator. But other than that plus namespaces, it's not using features that aren't available in C. I disagree that it uses most features of the language, at least not in any direct or visible way. There are a lot of features it doesn't use.
- danieldk 16y agoEven if one uses a tiny subset of C++, the new standard provides many improvements suited for nearly any subset. For instance: - Expected notation for angle brackets (vector<vector<string>> versus vector<vector<string> >). - Type inference using the 'auto' keyword. - Initializer lists. - Range-based loops. - Strongly-typed enumerations. - Delegation in constructors (constructor-constructor calls). - Incorporation of TR1, which brings stuff like shared_ptr and containers based on hashing (unordered_map/unordered_set).
- cageface 16y agoType inference using the 'auto' keyword. This is the one I'm looking forward to. Maybe I won't have to typedef every stl container I use just to make my code readable.
- deleted 16y ago[deleted]
- rwmj 16y agoBut compared to real type inference? In languages which have been around since the early 80s?? Just being able to infer the type in the right side of an expression is rubbish.
- cageface 16y agoOf course, but I can't use any of those languages to implement commercial audio units so I'm happy to have something in the one language in which I can.
- rwmj 16y agoReally? You've actually (and verifiably) tried this or not?
- cageface 16y agoMaybe you've never written audio unit or vst plugins? This is a domain in which C++ virtual functions are considered too slow, not to mention things like garbage collection. There's a reason everybody writes this stuff in C++ (and often assembly).
- 16s 16y agoThe new unorder containers are very nice. They are containers based-on hash table data structures and are very fast for certain problems. It's nice to have them in the standard.
- d0m 16y agoJust anonymous function would make a huge difference. Presently, you have to use boost or create new classes (Yes, you need to write a class for any anonymous function! (See Effective Stl, item 46 for more details of why it is recommended)). So, taken from: http://www2.research.att.com/~bs/C++0xFAQ.html#lambda http://www2.research.att.com/~bs/C++0xFAQ.html#lambda You could write something like: void f(vector<Record>& v) { vector<int> indices(v.size()); int count = 0; fill(indices.begin(),indices.end(),[&count](){ return ++count; }); // sort indices in the order determined by the name field of the records: std::sort(indices.begin(), indices.end(), [&](int a, int b) { return v[a].name<v[b].name; }); // ... }
- rwmj 16y agoWelcome to ... what? 1970? 1960? How many decades ago did other languages have anonymous functions?
- malkia 16y agoExactly! Now it's time for the assembly language to get anonymous lambdas too :)
- rwmj 16y agoIf only C++ was as useful as the odd bit of assembly programming.
- masklinn 16y agoLisp, 1958. Though technically they were invented in 1936 by Alonzo Church (in his Lambda Calculus).
- extension 16y agoI hope they at least beat Java to it.
- killedbydeath 16y agoThere are function pointers in C and they are used to pass logic into C/C++ functions. They are not anonymous, and are more awkward to use than the new syntax, but they covered many use cases.
- SamReidHughes 16y agoThe important lesson here is that the only way to fix C++ is by making it even more complicated. This may sound like a joke, but it is in fact the truth.