Search code examples
c++cgal

Will unsuccessful call alter by-reference passed result?


Not sure if this question is plain C++ or library specific. I want to know, if functions, that return success code and output their result to a passed reference alter output reference in case of failure?

The library used is CGAL

using namespace PMP = CGAL::Polygon_mesh_processing;
Mesh out;
bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out);

Solution

  • There's nothing special about returning a true or false value from a function; i.e. whether your function returns success or failure has no meaning whether it changed the arguments:

    bool do_something(int& a, int& b) {
        a += ++b;
        return false;
    }
    

    still changes a and b, no matter whether you return false or return true.

    It's hence a thing that the author of that function decided when they wrote that function. I hope they documented what they do!