Friday, August 18, 2023

error: cannot bind non-const lvalue reference ... to an rvalue ...

It took me way too long to figure out, so posting it here. This:
error: cannot bind non-const lvalue reference of type 'int32_t&' {aka 'long int&'} to an rvalue of type 'int32_t' {aka 'long int'}
means: You tried to pass a uint32_t to a method that accepts a reference to int32_t (signed integer). GCC would have to create a temporary to hold the conversion, but passing a temporary by-reference is not allowed. It'd help if the type difference stood out more. But it also shows my C++ has gone very rusty from too many years of using postgres-dialect C and golang.