Worked OK? But what?
I do not define anything!
It was just a simple example,
but what if I want to convert other floating point numbers,
nut just 0, 1, -1,
for example I want to convert signum == 2 -> double NaN,
so I want to define a casting function:
>so I want to define a casting function:
So do it. We're not talking about rocket science here:
double to_double(signum s);
Or are you going to complain that double(s) is so vastly superior to to_double(s) that you absolutely must have a user-defined cast that uses exactly the same syntax as the native cast? :icon_rolleyes:
>It is not possible to define "real" casting?
What I see here is the difference between a professional attitude and an amateur attitude. Yes, it is possible, but it's less clear, takes longer to implement, requires more effort to maintain, and doesn't really buy you anything for the added complexity. One with an amateur attitude will do it anyway while one with a professional attitude will crank out something simple in a few minutes (a function, perhaps?) and spend valuable time on more important things.