Slashdot Mirror


C++14 Is Set In Stone

jones_supa (887896) writes "Apart from minor editorial tweaks, the ISO C++14 standard can be considered completed. Implementations are already shipping by major suppliers. C++14 is mostly an incremental update over C++11 with some new features like function return type deduction, variable templates, binary literals, generic lambdas, and so on. The official C++14 specification release will arrive later in the year, but for now Wikipedia serves as a good overview of the feature set."

8 of 193 comments (clear)

  1. Re:Stone by NotInHere · · Score: 4, Informative

    Actually, its set in {La,}Tex: https://github.com/cplusplus/d...

  2. Re:Still... by tlhIngan · · Score: 4, Informative

    ...using c. Although I do like to comment thusly, and so prefer a compiler that understands at least basic c++: // comment

    I like to stay as close to the metal as I can get. I'd use assembler, but many of my projects are cross platform, so c it is.

    End of Line terminated comments ("//") actually are in the C spec as part of C99. And while it did take GCC a little while for that to be accepted in C mode, most other commercial compilers accepted them just fine. (C++ is not completely compatible with C, mind you, unlike Obj-C which is fully C compatible. This can cause issues if you try to compile C code using a C++ compiler rather than a C/C++ compiler)

    Now, one interesting thing in C++14 is binary literals (using "0b" a la "0x" for hex). That seems handy, though it would be more appropriate to be in C than C++ as C generally needs that sort of specification. Though, annoyingly, they didn't seem to allow use of something like _ to break long literals up into human-readable groups. I mean, a 32-bit string of bits is already hard enough to visually see, allowing the use of something like "_" in the string to help arbitrarily break up and group long constants would be helpful. (Even in hex it would be useful when doing 64-bit values).

    E.g., would you rather try to see which bit is set in a string like "0b001011010011011101011100" or have it broken up like "0b0010_1101_0011_0111_0101_1100" or "0b00101101_00110111_01011100". If it's a bit field, you may even want "0b001011_010011011_01_0_111_0_0" if breaking it into fields has meaning.

    Such a small change to help readability...

  3. Re:Still... by Anonymous Coward · · Score: 5, Informative

    Though, annoyingly, they didn't seem to allow use of something like _ to break long literals up into human-readable groups.

    Yes they did. It's not underscore, it's apostrophe. For example:
            auto a = 0b100'0001; // ASCII 'A'
            auto million = 1'000'000;

    See here:
            http://isocpp.org/wiki/faq/cpp14-language#digit-separators>http://isocpp.org/wiki/faq/cpp14-language#digit-separators

  4. Re:Still... by Imagix · · Score: 5, Informative

    Uh, yes they do. Don't rely on summaries to list all of the features of the language. From N3797: An integer literal is a sequence of digits that has no period or exponent part, with optional separating single quotes that are ignored when determining its value. Example: The number twelve can be written 12, 014, 0XC, or 0b1100. The literals 1048576, 1’048’576, 0X100000, 0x10’0000, and 0’004’000’000 all have the same value. — end example

  5. Re:Why do we need Auto? by erapert · · Score: 4, Informative

    Herb Sutter responded to this on his blog (Sutter's Mill): http://herbsutter.com/2013/08/...

  6. Re:Why do we need Auto? by kthreadd · · Score: 5, Informative

    Auto does not mean loose typing. It still has a type, you just don't have to write it but it will be there and will be enforced by the compiler.

  7. Re:Why do we need Auto? by Xrikcus · · Score: 4, Informative

    Lambdas are a primary place where auto is there precisely because C++ is a strong, statically typed language as far as possible. The alternative might be polymorphic lambdas, which would require dynamic typing. With auto the type you get, and can propagate through templates, is the type of that specific lambda. With polymorphism the type you'd get is the type of a lambda, from which you'd need to infer which lambda. Auto ensures that with a lambda, though the type is not easily known to the programmer, the type can be statically defined in the code and propagated accordingly.

  8. Re:Oh god so what? by TheRaven64 · · Score: 4, Informative

    Integer overflow has absolutely nothing to do with security

    Integer overflow has been in the top five causes of CVEs for several years running. Buffer overflows, sadly, are still at the top.

    --
    I am TheRaven on Soylent News