Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

C++14: Through the Looking Glass

Download

Right click “Save as…”

Zip

“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?

 

Follow the Discussion

  • 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
    };

  • 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);
    

     

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

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

  • berkusberkus

    What would you guys think about named function arguments?

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

  • phampham

    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

Remove this comment

Remove this thread

close

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.