> returning more than 1 object from a function without return pointers in the args
Actually that’s solved by returning `std::tuple` and `std::tie` – or using custom classes.
Except that it is a bit less error prone. When using std::tie, your have to know the order in which the argument are returned, and you will have bugs the day the maintainer of the library will change it. With iod, you code does not depend on this order anymore.
Re:Show HN: C++11 inline object definitions
by unfamiliar on Wednesday May 07, 2014 @01:03PM
(#7711330)
> using std::tie, your have to know the order in which the argument are returned
How is this any different than needing to know the order in which the arguments are passes? (Which I happen think is a problem that needs solved.)
The slight difference is that the order of the arguments is stated in the api of the library (which does not solve the problem though). The problem may be solved by passing an iod as single argument:
fun(iod(arg1_ = 1, arg2_ = "foo"));
or by using method chaining :
http://www.parashift.com/c++-faq-lite/named-parameter-idiom....
job security and returning more than 1 object from a function without return pointers in the args