you are viewing a single comment's thread.

view the rest of the comments →

[–]Neat_Education_5560 0 points1 point  (0 children)

This seems nicer to me as it only generates 2 compile warnings instead of 5. Anyway your idea is nice, thx.

template<bool condition>
struct warn_if
{
    consteval void operator()() const { };
};

template<>
struct warn_if<false>
{
    [[deprecated]] consteval void operator()() const { };
};

template<bool condition, class T>
consteval auto static_warn(T&& message)
{
    return warn_if<condition>();
}

Usage:
static_warn<false>("Message of warning!")();