Because the type of geom.data
is int*
, you cannot refer to it with a reference to int const*
. In order to make a reference to an int const*
, first you need an int const*
. So there must be a conversion, so a new pointer of a new type must be created, and so it must be a temporary.
Do you need the caller of the function to be able to change what the pointer in the geom object points to? It would seem not, since you are making the pointer itself const. So just drop the reference, and you can keep the const.