I have a struct with a static field I want to deprecate. However, for now I still want to initialize it. The following snippet produces a warning under MSVC and GCC (but not Clang):
struct A {
~A();
};
struct B {
[[deprecated]] static A X;
};
A B::X; //warning C4996: 'B::X': was declared deprecated
Interestingly, if I remove ~A();
, the warning disappears.
Is there way to initialize B::X
without producing a warning, without resorting to hacky pragmas or such?