The Goal
I would like an overloaded function that can handle having the struct on the right-hand side of the operator.
Overload "<<" operator to achieve;
std::cout << vec3 << std::endl;
Where I Am
Struct;
struct vec3
{
float x;
float y;
float z;
std::ostream& operator << (std::ostream &o)
{
return o << x << y << z;
}
}
Attempts;
std::cout << vec3(0,0,0) << std::end;
Tells me that "No Operator Matches Operands"
vec3(0,0,0) << std::cout << std::endl;
Gives me the desired result, however this is not how I would prefer to layout code like this.
It may be the case I am misinterpreting the error messages but this is what I am gathering from it.
I am struggling to find any particularly concise resources for the syntax required to handle an operation where the struct is on the right-hand side of the operator. In the form:
OTHER_TYPE OPERATOR STRUCT
As apposed to:
STRUCT OPERATOR OTHER_TYPE