So, my real class is more complicated than this, but this illustrates the point. In general, it seems like the compiler doesn't know that if you get to the assignment operation in foo::set that the two types are the same, so it complains. Using a type cast doesn't work generally because the casts between certain types are not defined, and again, the compiler isn't smart enough to know that at that statement, the types are the same. I can use the above method to trick the compiler, and it seems safe to me since I know that the types are exactly the same. But, is this safe? And is there a better way to deal with this? Thanks
The actual class is much more complicated. It uses a variadic template and it seems like the compiler wants the assignment operation to be valid for each type in the parameter pack.
Edit: I modified the original post to give a more informative description of the class.