goertzenator / nifpp

C++11 Wrapper for Erlang NIF API
125 stars 61 forks source link

accept rvalue tuples of lvalue references #1

Open goertzenator opened 10 years ago

goertzenator commented 10 years ago

nifpp::get should accept an rvalue tuple consisting of lvalue references. Currently only lvalue tuples are accepted.

We want the following to work:

int a,b; nifpp::get_throws(env, term, std::tie(a,b)); // crack {123, 456}

chrta commented 9 years ago

Please have a look: https://github.com/chrta/message_queuex/commit/8a57b6aabf796814b9bf795fc727323d7a6cc652

This works with std:tie() and std::tuple().

goertzenator commented 9 years ago

I also have an uncommitted variation that implements rvalue tuples, but I think it had some limitations. Consider some of these wrinkles:

  1. What happens if the user provides an rvalue tuple that has something other than an lvalue referenence (ie, a value or rvalue reference)? The program should fail to compile in this case.
  2. What about nested rvalue tuples? This makes sense and should be supported, but as per #1 the compile should fail if any "leaf" node is not an lvalue reference.

I didn't try your code so I don't know how it holds up to the above properties, but I think I had some problems with them in my code. I'll have to take a closer look (and add unit tests) to see if either of us actually resolved them.