Basically what i want to do is something like this:
struct target {
int somevalue;
}
struct target_wrapper {
target t;
target_wrapper(float v) : t(target{(int)v * 1024}){}
operator target() { return t; }
}
target t = 1.0f; // would be called as t = (target)((target_wrapper)1.0f)
I can not change the target structure since there is code expecting it to be a POD. I now that the C++ standard says its only allowed to use one user defined conversion but maybe there is some magic trick one could use here instead of using a function.
target make_target(float a){ return target{(int)a*1024}; }
target t = make_target(1.0f);
Would work but it is rather annoying since all I really do is multiply the float by 1024.