ThisClass () statement causes a stack overflow
I want the class to be simple and not define a constructor, so I can make the data Pt = {0, 5}; so I figured the best way to convert Pt_t from short to long or vice versa is to do something like this.
template <class T>
struct Pt_t
{
T x, y;
template <class T2> operator Pt_t<T2>() { Pt_t pt = {x, y}; return pt; }
};
The compiler dislikes this and calls the Pt_t operator when it returns pt; thus getting a stack overflow. How can I prevent this? the only solution I can think of is that Pt_t uses constructors that remove Pt_t pt = {1, 2}; which I prefer to keep if I can.
+1
user34537
source
to share