C++14: Through the Looking Glass

Sign in to queue

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

Add Your 2 Cents