Reducing Signed and Unsigned Mismatches with std::ssize() -- Bartlomiej Filipek

Do you know about std::ssize()?

Reducing Signed and Unsigned Mismatches with std::ssize()

by Bartlomiej Filipek

From the article:

In this article, I’ll show another technique that avoids mixing signed and unsigned types.

In my article Integer Conversions and Safe Comparisons in C++20 we learned about cmp_* integer comparison functions that allow us to compare various types of integer types. The functions are safe because they help with mixing signed and unsigned types. In C++20, there’s another handy feature: the non-member std::ssize() function that returns a signed number of elements in a container.

Let’s see how to use it...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.