C++14: Through the Looking Glass

Download this episode

Download Video

Description

“The time has come,” the ISO said, “To talk of many things:  Of move-capture—and literals— Of making lambdas sing— And why deduction is so hot— And if digits should grow wings?”

So have you heard of the next C++ Standard? No, it is not C++11. Even though C++11 has just been ratified, C++14 will likely replace C++11 by next year. By now, we have enough experience with C++11 to know where we are missing various fingers and toes such as:

  • Why do we not have move capture in lambdas? 
  • How about some real user-defined literal suffixes? 
  • Why did we stop with monomorphic lambdas? 
  • If lambda returns can be deduced, why not normal functions? 
  • Could we get digit separators?

C++14 will be more than a bug-fix release, and will contain some important enhancements on top of C++11. It will remove some of the major annoyances from C++11, that we already know of. But more importantly, how will this change the language, library and some important idioms?

 

Download:

Zip

Day:

2

Code:

009

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      khourig

      What about back tick (`) as a number group separator?

      This could work for decimal (1`000`000) or hex (0xFFFF`0000) literals. Also, the proposed binary literals (0b0101`1000). If it were an ignored part of the number syntax, it would also make column alignment easier within tables.

      static const char table[] = {
        ``0, ``1, ``2,
        `10, `11, `12,
        100, 101, 102
      };

    • User profile image
      aklimkin

      Not sure that issue with a number group separator worth the effort... In a few cases where you would really need it, you can use preprocessor.

      #include <boost/preprocessor/cat.hpp>
      #include <boost/preprocessor/facilities/empty.hpp>
      #include <boost/preprocessor/variadic/size.hpp>
      #include <boost/preprocessor/control/if.hpp>
      #include <boost/preprocessor/facilities/empty.hpp>
      
      #define N(X, ...) BOOST_PP_CAT(X, BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), BOOST_PP_EMPTY(), N(__VA_ARGS__)))
      
      int n = N(100,200,100);
      

       

    • User profile image
      vittoriorom​eo

      I'm one of those people who would greatly prefer `strong typedefs` to user-defined literals... is there any proposal already?

    • User profile image
      Matt_PD

      @vittorioromeo:

      Yes, see N3741, "Toward Opaque Typedefs for C++1Y, v2" by Walter E. Brown:
      http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3741.pdf

    • User profile image
      berkus

      What would you guys think about named function arguments?

      A proposal for syntax I've got here https://github.com/berkus/cpp_named_args

    • User profile image
      pham

      Since there is new user defined literal, why don't you use the string + suffix + comma as separator and the compiler will figure it out at compile time for long number const

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.