I want to write a c++ function and pass it a struct parameter like this:
struct vec2 {
float x,y;
};
void func(vec2 v);
int main() {
func(vec2 { 10, 20 } ); // argument value from constructor
}
I want my function to take a reference instead but I get an error.
void func(vec2 &v); // reference instead of value
int main() {
func(vec2 { 10, 20 } ); // error: No matching function for call to 'func'
}
Is it possible to pass this argument by reference instead of by value without moving the constructor outside of the function call?