
AMDG Paul A. Bristow wrote:
Looks like the warnings occur depending on the types used in the unit tests. For example, the warning mentioned above comes from the test code:
typedef variant< short, const char* > t_var2; typedef variant< unsigned short, const char*, t_var2 > t_var5; typedef variant< unsigned short, const char*, t_var5 > t_var6;
t_var6 v6; v6 = 58;
Which looks like a legitimate warning about converting an integer (58) to a
short.
Since this is expected, could the test use a static_cast to the right type?
v6 = static_cast< t_var6 >(58);
Does this quiet the warning?
Or must it be v6 = static_cast< unsigned short >(58); ?
Either way this would document that casting/converting takes place?
And perhaps users should do this too? The static_cast documents that the author has thought about this.
I'd be careful about adding a static_cast, since it changes exactly what's being tested. Part of the behavior of a class is the way it handles implicit conversions. Even conversions that generate warnings sometimes need to be tested. In Christ, Steven Watanabe