For this snippet
const std::vector<int> v;
if (v.size() != 1) {} // could call operator!=()
the code complies cleanly even at high warnings levels (all warnings enabled in Visual Studio 2022). However, if I pass the arguments to a function
const auto f = [](auto&& lhs, auto&& rhs) { if (lhs != rhs) {}};
f(v.size(), 1);
the compiler generates a '!=': signed/unsigned mismatch warning.
How can I make the function behave the same way as the "inline" code, i.e., no warning?
Keep in mind that the "real code" is something like
#define f(lhs, rhs) if (lhs != rhs) {}
I'd like to "do the 'right thing'" and replace the macro with a function
temmplate<typename TLhs, typename TRhs>
inline void f(TLhs&& lhs, TRhs&& rhs)
{
if (lhs != rhs) {}
}