Previous section   Next section

Imperfect C++ Practical Solutions for Real-Life Programming
By Matthew Wilson
Table of Contents
Chapter 29.  Arithmetic Types


29.5. Assignment

This is actually reasonably easy if we choose to rely on conversion constructors. Again, because UInteger64 is a value type that does not handle resources, we can leave the assignment operator for the compiler to define. What this means is that any expression containing assignment to an instance of UInteger64 will succeed if the right-hand side expression can be converted to UInteger64, that is, it matches a constructor. Hence, the following all succeed, since the constructors also succeed.



UInteger64 i;


unsigned   i2 = . . .


uint64_t   i3 = . . .


UInteger64 i4;





i = 0;


i = i2;


i = i3;


i = i4;




      Previous section   Next section