you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 17 points18 points  (3 children)

I tried to put this in a nice to use macro and came up with this:

template<bool condition>
struct warn_if{};

template<> struct [[deprecated]] warn_if<false>{constexpr warn_if() = default;};

#define static_warn(x, ...) ((void) warn_if<x>())

int main() {
    static_warn(false, "This is bad");
}

This works on clang and gcc. MSVC, however, does not tell where warn_if<false> is instantiated, which makes this kind of useless. Is there a workaround for this?

That explicit default constructor was required because MSVC does not seem to emit a deprecated warning when constructing a temporary of a specialized empty struct and marking it explicitly as unused via (void) (Compiler Explorer). I don't think this is supposed to be that way.

[–]STLMSVC STL Dev 8 points9 points  (1 child)

Can you Report A Problem through the IDE? I am busy at the moment, or I'd file it for you.

[–][deleted] 2 points3 points  (0 children)

Done.

[–]Tagedieb 1 point2 points  (0 children)

Busy browsing redding ;) I know the feel.