strange tostring() behaviour

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

strange tostring() behaviour

anders langlands
My TypedArray<T> class has a getter function:

const T& get( uint32 index ) const
        return array[ index-1 ];

and the ostream operator << for the Vec3 class is defined as:

template <class T>
std::ostream &    operator << (std::ostream &s, const Vec3<T> &v);

typedef Vec3<float>  V3f;

yet when I try to print a V3f I get back from an array in Lua like so:

print( array:get( index ) )

I get the following error:

no overload of  'V3f:__tostring' matched the arguments (const V3f)
candidates are:
V3f:__tostring(lua_State*, V3f&)

If I change get() to return a 'T' instead of a 'const T&' it works fine. Any idea what could be causing this?