Search code examples
c++icc

Fix 3rd party library code initialization of a class member function reference parameter with a constant


When compiling a 3rd party library, I get "error: initial value of reference to non-const must be an lvalue". The error is occurring in a C++ Class definition in this declaration of a member function:

bool intersectsHierarchy(ON_Ray& ray, std::list<BVNode<ON_BoundingBox>*>& results = 0);

Based on information I found on the web, I tried to make the initialized parameter be const, as follows:

bool intersectsHierarchy(ON_Ray& ray, const std::list<BVNode<ON_BoundingBox>*>& results = 0);

But that just causes another compilation error.

Any ideas how to best fix this and get my library to compile?


Solution

  • remove the = 0 part -

    1. You cannot assign 0 to a list
    2. You can only pass a variable by reference not a const value