Hacker News new | ask | show | jobs
by textminer 4602 days ago
I've basically freshly come to C++ in a work environment, and C++11 is all I've learned so far. Range-for loops and smart pointers and move semantics are wonderful. I still haven't adopted to a perfect idiom for calling functions, though: It's straightforward if I call a function and it returns a single object with move semantics. But what if I want to mutate multiple things with a function call (say, go through a vector and throw out indexes below a certain threshold, updating an unordered_map so as to specify the names and locations of certain columns). Do I return one, while changing the other by reference? Do I return a pair or a struct that only exists for me to quickly unpack? Do I make the function void and change both by reference?