Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming Software Upgrades

C++14 Is Set In Stone 193

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."
This discussion has been archived. No new comments can be posted.

C++14 Is Set In Stone

Comments Filter:
  • Stone (Score:5, Funny)

    by buchner.johannes ( 1139593 ) on Tuesday August 19, 2014 @10:33AM (#47703709) Homepage Journal

    Wouldn't it more useful for it to be set in silicone?

    • Re: (Score:3, Informative)

      by makq ( 3730933 )
      Silistone!
    • Still... (Score:4, Interesting)

      by fyngyrz ( 762201 ) on Tuesday August 19, 2014 @10:37AM (#47703739) Homepage Journal

      ...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.

      • Re:Still... (Score:5, Funny)

        by makq ( 3730933 ) on Tuesday August 19, 2014 @10:43AM (#47703783)
        Various black hats appreciate your dedication to C.
      • Re:Still... (Score:5, Informative)

        by tlhIngan ( 30335 ) <slashdot@worf.ERDOSnet minus math_god> on Tuesday August 19, 2014 @10:52AM (#47703853)

        ...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...

        • I don't know if it was officially accepted, but I believe they added ' as a digit-group separator: 0b0010'1101'0011'0111'0101'1100
        • Re:Still... (Score:5, Informative)

          by Anonymous Coward on Tuesday August 19, 2014 @11:13AM (#47704049)

          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

        • Re:Still... (Score:5, Informative)

          by Imagix ( 695350 ) on Tuesday August 19, 2014 @11:14AM (#47704059)
          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
          • by romiz ( 757548 )
            Why did they go for this ? Ada introduced the underscore years ago, Java followed in Java 7 recently, and for example Rust uses the underscore as well. And it also allows multiple separators, which allows for aligning the columns in bitmasks for example, while it's forbidden in C++. See the Java specification [oracle.com] for example.
        • 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...

          If you're really interested in readability you would probably define those bits, like:

          #define HIGHSTUFF (0b001011 << 17)
          #define NOTSOHIGHSTUFF (0b010011011 << 8)

          and then or them together.

          Alternatively you could define a macro for your bit field, like:

          #include
          #define bitfield(a,b,c,d) 0x##a##b##c##d
          int main() {
          printf("%x", bitfield(f,f,f,f));
          }

        • > Now, one interesting thing in C++14 is binary literals (using "0b" a la "0x" for hex).

          Hey, it only took ~40 years for a C based language to add binary literals! (It will only take another 40 to standardize pragmas such as struct packing.)

          Using 0b is dumb. They should of used a letter that isn't in hex, say 0z1101.

          Using '_' would of been nice but the C++ community doesn't really have a fucking clue about solving real-world problems. Witness ...

          Herb Sutter looking into adding Cario 2D into C++
          "http://de

          • Using 0b is dumb. They should of used a letter that isn't in hex, say 0z1101.

            There's nothing dumb about it at all. First of all, the prefix 0b cannot be confused with a hex digit because you need the prefix 0x to get hex.

            Secondly, if you're concerned about b looking like a hex digit, well, there's your problem. Lowercase hex digits are the devil's work. Always write hex digits using uppercase letters, as $DEITY intended.

            Finally, what the hell is the z supposed to stand for in 0z?

            • Re: (Score:2, Funny)

              Finally, what the hell is the z supposed to stand for in 0z?

              He's probably a German speaker. Binary is Zeugenschutzprogramm in German.

        • ...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...

          What on Earth are you talking about?? Using C++ comments in C was a GCC extension that made it into C99.

      • Year, it is really annoying that 'computers' don't really contain metal any,ore now as all important parts are made from semi conductors, I feel your pain :-/

    • by fyngyrz ( 762201 ) on Tuesday August 19, 2014 @10:39AM (#47703757) Homepage Journal

      Wouldn't it more useful for it to be set in silicone?

      Intend to stay abreast of the spec, do you?

    • *silicon

    • Wouldn't it more useful for it to be set in silicone?

      Assuming you mean silicon, then; no - Setting things in stone is better than writing them in the sand.

    • Re:Stone (Score:5, Informative)

      by NotInHere ( 3654617 ) on Tuesday August 19, 2014 @10:47AM (#47703819)

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

    • by cluening ( 6626 )

      Sounds a bit wobbly. Maybe silicon instead?

    • I think you mean Sillicon

      silicone:
      Any of a class of synthetic materials that are polymers with a chemical structure based on chains of alternate silicon and oxygen atoms, with organic groups attached to the silicon atoms. Such compounds are typically resistant to chemical attack and insensitive to temperature changes and are used to make rubber, plastics, polishes, and lubricants.

  • by EMG at MU ( 1194965 ) on Tuesday August 19, 2014 @11:17AM (#47704087)
    I liked a lot of the C++11 features. Lambdas, move semantics, std::mutex, and consistent initializers are all cool things.

    Looking at C++14 I see a lot of expansion of the support of the auto type. I have not found a scenario where I perer auto, so I'm curious about such a large focus on it.
    • by e r ( 2847683 ) on Tuesday August 19, 2014 @11:40AM (#47704305)
      Herb Sutter responded to this on his blog (Sutter's Mill): http://herbsutter.com/2013/08/... [herbsutter.com]
    • Re: (Score:3, Interesting)

      by Anonymous Coward

      I used to think that, until I realized:

      auto handler = boost::bind(&Class::write_callback, this, boost::ref(timer), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred);

      /// what is the type of handler?
      boost::asio::async_write(device, buffer, handler);

      Iterators another good one:

      typedef void (*FunctionPtr)();
      std::map<std::string, FunctionPtr> knownCommands;

      /// elsewhere:
      std::string command = "example";

      /// what do you like more?
      std::map<std::string, FunctionPtr>::it

    • Re: (Score:3, Informative)

      by Anonymous Coward

      There are several cases where auto is critical.

      For instance with lambdas, it is no longer even possible to write out the types:

      auto itr = boost::make_filter_iterator([](const Bar &bar) {return bar.foo;},vect.begin(),vect.end());

      The type of itr is boost::filter_iterator, but it cannot be written out because there is no way to enter to the type of the lambda.

      It also eliminates nasty hacks like you see in BGL:

      property_map::const_type pm = get(vertex_index,graph);

      The property_map specialization framework is

    • by fnj ( 64210 )

      This does not address your question specifically, but C++14 fixes some glaring holes in C++11. Well, one hole for damn sure. They clean forgot to put std::make_unique in C++11, even though std::unique_ptr was there. The hole was obvious to anyone who saw std::make_shared and then went to try and look up its obvious complement.

      It was also high time and way beyond high time they added binary constants. Frustrating as hell they STILL found it too hard to support binary formatting in iostreams, though. Evidentl

    • by Stele ( 9443 ) on Tuesday August 19, 2014 @12:12PM (#47704575) Homepage

      auto definitely makes writing looping constructs with iterators shorter/easier, without additional typedefs, but by far the nicest use for it is in writing templates, where a specialization or type-dependent mapping my occur in the template using a helper function, and you don't necessarily know what the intermediate type might be. Sure, you could use some complicated typedefs, which may require additional traits classes, but auto handles it nicely.

    • by godrik ( 1287354 )

      I use auto a lot. auto (or equivalent syntax) are used a lot in functional programming languages. Mostly in short functions where I do not really care what the proper typename is. It is clear how the variable behaves and that is I care about it. Often, I know I get some kind of iterator, but the actual type might not be easy to find. In particular, it might depend on a template parameter. So I guess I could add plenty of typedefs to get an easy to write type. But what is the point really?

  • by Tough Love ( 215404 ) on Tuesday August 19, 2014 @11:20AM (#47704127)

    It's just pathetic that so many years down the road the committee can't get its act together to provide this much loved C99 feature at least for POD. This is a major issue, if not the major issue) with porting C code. The word wanking comes to mind. Here, GCC guys really need to take the lead but it's starting to feel like GCC guys are actually holding back on it. It's not like the coding is a challenge.

    • You want the committee to focus on practical problems?! LOL. You are more delusional then them! :-)

      Recently they wanted to add a 2D graphics API to the language! Yeah, let's re-implement OpenGL ES.
      http://developers.slashdot.org... [slashdot.org]

      This is your typical design-by-committee of a "Solution looking for a Problem". God forbid we actually have _standardized_ pragmas like we do for OpenMP.

      The committee has only one motivation:

      "Job security by obscurity."

      C++ has a become a total cluster-fuck of over-engine

    • by fnj ( 64210 )

      HEAR, HEAR!!! [Pounds fist on table repeatedly]. I have been dying for this since gcc added the nonstandard extension and then C99, seems a lifetime ago, codified it in the C standard. What the HELL, guys. With all the wang-yanking ivory tower crap they did implement in C++11 and 14, much of it very hard work to master using, let alone implementing, is there any way in hell you can blame us for calling you out on the immature assholery of not simply copying this dead-simple feature from C99?

      This should have

    • by Stele ( 9443 )

      Maybe it's not part of C++ because this kind of initialization is trivial to do, and more readable, with helper classes and constructors. Just a theory - I wasn't even aware of designated initializers.

      What I find pathetic is all of the C programmers who still think C++ is slow, bloated, or impossible to understand.

      • Maybe it's not part of C++ because this kind of initialization is trivial to do...

        It is a safe bet that you have never ported a C99 program of any significance to C++.

      • this kind of initialization [performed with C99 designated initializers] is trivial to do, and more readable, with helper classes and constructors

        A designated initializer for static data can initialize data in a read-only section. "Helper classes and constructors" mutate an object, which inflates the size of your program's read-write section.

        • by Stele ( 9443 )

          Good point!

      • by mbkennel ( 97636 )
        I'm a C++ programmer.

        C++ is (usually) fast, bloated and almost impossible to fully understand.
    • by godrik ( 1287354 )

      Indeed! Where are concepts! These is the number 1 addition to C++ most of us need! I am sure that they were not added for a good reasons. But programming template is currently a nightmare because of the duck typing of the meta programming system.

      Dear standardization committee, we NEED a solution to the template compile time debugging problem.

    • Yes!!! I wish I had mod points. They basically had them ready to go for C++11 and then committee infighting killed them (Bjarne stubbornly backed the wrong horse - not that I have a strong opinion on this or anything ;) ).

      Syntactic support for generic programming would be the single best addition to C++ to breathe new life into the language and get a whole generation of developers who've written it off interested in it. Generic programming is as paradigm shifting as OOP. It just kills me that it's so t
  • by doti ( 966971 ) on Tuesday August 19, 2014 @12:52PM (#47704947) Homepage

    now we just need to throw the stone in the Marina Trench.

  • by T.E.D. ( 34228 ) on Tuesday August 19, 2014 @02:39PM (#47705895)

    with some new features like function return type deduction,

    Hey, K&R C had function return type deduction back in the 70's .

    ...of course it always guessed "int", but IT HAD IT.

  • ...C++14 decays [wikipedia.org] to N++14 as well.

Technology is dominated by those who manage what they do not understand.

Working...