math: document add and mul

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-09-25 14:54:46 +02:00
parent 41d764eeef
commit 4a5970595f

View File

@ -11,6 +11,14 @@
namespace stdex namespace stdex
{ {
///
/// Multiplies two numbers and throws on overflow
///
/// \param[in] a First operand
/// \param[in] b Second operand
///
/// \return a * b
///
inline size_t mul(size_t a, size_t b) inline size_t mul(size_t a, size_t b)
{ {
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
@ -30,6 +38,14 @@ namespace stdex
throw std::invalid_argument("multiply overflow"); throw std::invalid_argument("multiply overflow");
} }
///
/// Adds two numbers and throws on overflow
///
/// \param[in] a First operand
/// \param[in] b Second operand
///
/// \return a + b
///
inline size_t add(size_t a, size_t b) inline size_t add(size_t a, size_t b)
{ {
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300