A compiler not accepting the metioned snippet is faulty, the code provided is legal and should not yield a fatal diagnostic during compilation. In other words; msvc is doing it wrong.
RELEVANT SECTIONS OF THE STANDARD
12.3.2 Conversion functions
[class.conv.fct]
2 A function may be
explicit
(7.1.2), in which case it is only considered as a user-defined conversion for direct-initialization (8.5). Otherwise, user-defined conversions are not restricted to use in assignments and initializations.
8.5 Initializers
[dcl.init]
16 The initialization that occurs in the forms
T x (a);
T x {a};as well as in
new
expressions (5.3.4),static_cast
expressions (5.2.9), functional notation type conversions (5.2.3), and base and member initializers (12.6.2) is called direct-initialization.
HOW WOULD I WORK AROUND MSVC++
BEING FAULTY?
use
typedef radians<float> rads;
instead ofusing
, and either;remove
explicit
from your conversion function, or;initialize your variable using
auto r = rads { d }
orauto r = rads (d);
.