Out Parameters, Move Semantics, and Stateful Algorithms -- Eric Niebler

In this article, Eric Niebler discusses an issue of API design regarding the age-old question of out parameters versus return-by-value, this time in light of move semantics. He uses std::getline as his example.

Out Parameters, Move Semantics, and Stateful Algorithms

by Eric Niebler

From the article:

I think getline is a curious example because what looks at first blush like a pure out parameter is, in fact, an in/out parameter; on the way in, getline uses the passed-in buffer’s capacity to make it more efficient. This puts getline into a large class of algorithms that work better when they have a chance to cache or precompute something.

 

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.