-edit- i am trying to close the question. i solved the problem with boost::is_base_and_derived
In my class i want to do two things. 1) Copy int, floats and other normal values 2) Copy structs that supply a special copy function (template T copyAs(); } the struct MUST NOT return int's unless i explicitly say ints. I do not want the programmer mistaking the mistake by doing int a = thatClass;
-edit- someone mention classes dont return anything, i mean using the operator Type() overload.
How do i create my copy operator in such a way i can copy both 1) ints, floats etc and the the struct restricted in the way i mention in 2). i tried doing
template <class T2>
T operator = (const T2& v);
which would cover my ints, floats etc. But how would it differentiate from structs? so i wrote
T operator = (const SomeGenericBase& v);
The idea was the GenericBase would be unsed instead then i can do v.Whatever. But that backfires bc the functions i want wouldnt exist, unless i use virtual, but virtual templates dont exist. Also i would hate to use virtual
I think the solution is to get rid of ints and have it convert to something that can do .as(). So i wrote something up but now i have the same problem, how does that differentiate ints and structs that have the .as() function template?