News for hackers. Stuff that matters.
Re:Named tuple for C++ by GreaterFool on Saturday January 02, 2016 @05:05PM (#10828220)
One great use of named tuples would be named function arguments. I've grown tired of seeing functions that take a bunch of doubles and always checking which argument is which.
Re:Named tuple for C++ by tbirdz on Saturday January 02, 2016 @05:57PM (#10828420)
This would be a case where C99 style designated initializers would come in handy in C++.

For example if you have a struct like:

  struct data {
      double w;
      double x;
      double y;
      double z;
  };
You can then create a struct of that type using syntax like:

  struct data d = {.w = 1.0, .x = 1.0, .y = 1.0, .z = 1.0};
Then you could have your functions take a struct data as a parameter, and use designated initializers to have syntax for keyword parameters.

I'm not sure why this feature never made its way into a C++ standard over the years.

Re:Named tuple for C++ by J_Darnley on Saturday January 02, 2016 @09:47PM (#10829274)
Don't forget that you can also have functions return a struct.
Re:Named tuple for C++ by petke on Saturday January 02, 2016 @07:27PM (#10828801)
I'd rather have something like Strong Typdef for that. Maybe we will get it eventually.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p010...