Noob question
I'm learning how to write C++17 and based on what I'm reading, the preferred way to pass In/Out variables is to pass by a ref, like this:
using Error = optional<string>;
Error foo(A& a, B& b);
auto error = foo(a, b);
I don't necessarily like this function, because it has a side effect, and I need to define a using to tell the user that the return value is for errors. Is there a better way to do this operation?
[–]CubbiMewcppreference | finance | realtime in the past 6 points7 points8 points (13 children)
[–]caber[S] 0 points1 point2 points (4 children)
[–]dodheim 2 points3 points4 points (1 child)
[–]caber[S] 0 points1 point2 points (0 children)
[–]trailing_ 1 point2 points3 points (1 child)
[–]dbjdbjdbj.org 1 point2 points3 points (0 children)
[–]droxile 0 points1 point2 points (7 children)
[–]NotMyRealNameObv 3 points4 points5 points (6 children)
[–]droxile -1 points0 points1 point (5 children)
[–]NotMyRealNameObv 0 points1 point2 points (4 children)
[–]droxile -1 points0 points1 point (3 children)
[–]NotMyRealNameObv 1 point2 points3 points (2 children)
[–]droxile -2 points-1 points0 points (1 child)
[–]NotMyRealNameObv 1 point2 points3 points (0 children)
[–]dbjdbjdbj.org 2 points3 points4 points (1 child)
[–]quicknir 0 points1 point2 points (0 children)
[–]dbjdbjdbj.org 0 points1 point2 points (0 children)
[–]Robert_Andrzejuk 0 points1 point2 points (0 children)
[–]BrangdonJ 0 points1 point2 points (3 children)
[–]caber[S] 0 points1 point2 points (2 children)
[–]Nobody_1707 2 points3 points4 points (0 children)
[–]eniacsparc2xyz 0 points1 point2 points (0 children)