By default, in C++, a single-argument constructor can be used as an implicit conversion operator. This can be suppressed by marking the constructor as explicit.
I’d prefer to make ‘explicit’ be the default, so that the compiler cannot silently use these constructors for conversion.
Is there a way to do this in standard C++? Failing that, is there a pragma (or similar) that’ll work in Microsoft C++ to do this? What about g++ (we don’t use it, but it might be useful information)?
Nope, you have to do it all by hand. It’s a pain, but you certainly should get in the habit of making single argument constructors explicit. I can’t imagine the pain you would have if you did find a solution and then had to port the code to another platform. You should usually shy away from compiler extensions like this because it will make the code less portable.