News for hackers. Stuff that matters.
Re:Unpacking Tuples in C++14 by phorese on Monday February 29, 2016 @05:42AM (#11194688)
If I just want to unpack a function's tuple result, I use "std::tie":

  tuple<int, bool, char> t = make_tuple(1, true, 'a');
  int  n = get<0>(t);
  bool b = get<1>(t);
  char c = get<2>(t);
can be written as

  int  n;
  bool b;
  char c;
  std::tie(n,b,c) = make_tuple(1, true, 'a');
This is not necessarily better or more dynamic, but at least it looks more pythonic (to me). One can even write

  std::tie(n,b,std::ignore) = make_tuple(1, true, 'a');
if not all results are needed!
Re:Unpacking Tuples in C++14 by jupp0r on Monday February 29, 2016 @01:58AM (#11193992)
The lengths one has to go in order to do unpack tuples show how a lot of things in modern C++ are built on top of an old boat, sadly.

Without pattern matching - ie structural decomposition - this is prohibitively unreadable and negates any benefits of better code reuse.

Re:Unpacking Tuples in C++14 by platform on Sunday February 28, 2016 @11:51PM (#11193648)
for a moment I thought that this would allow in C++ to create a 'python dictionary' like data structure for a run-time provided array of JSON objects (as an example), whose schema was known at compile time.

However tuples, do not appear to enable that.