Hello All,

So in doing some work on this subject, we have come across a case that
David and I believed was worth raising for discussion.

As one might expect, at some point, someone is going to pass in a buffer
and a length into a function and expect data put into that buffer, e.g.


On Tue, Oct 3, 2017 at 4:26 PM, Jacob Barrett <jbarr...@pivotal.io> wrote:

> Voting on the conversation around C++ return values vs. out parameters.
> This vote is to adopt the standard of return values over the use of out
> parameters. On functions that must return more than one value to use the
> C++11 std::tuple type for future compatibility with C++17.
>
> For example:
>
> std::tuple<int, std::string> foo::getAAndB() {...}
>
> And call it with:
>
> int a;
> std::string b;
> std::tie(a, b) = foo.getAAndB();
>
> Alternatively the tuple can be called like:
>
> auto r = foo.getAAndB();
> auto a = std::get<0>(r);
> auto b = std::get<1>(r);
>
> In C++17:
>
> auto [a, b] = foo.getAAndB();
>
>
>
> Rather than:
>
> int foo::getAAndB(std::string& b) {...}
>
> Called like
>
> std::string b;
> auto a = foo.getAAndB(b);
>
> -Jake
>

Reply via email to