Exiv2
Static Public Member Functions | List of all members
Safe::Internal::fallback_add_overflow< T, typename enable_if<!is_signed< T >::VALUE >::type > Struct Template Reference

Overload of fallback_add_overflow for unsigned integers. More...

#include <safe_op.hpp>

Static Public Member Functions

static bool add (T summand_1, T summand_2, T &result)
 Adds the two summands only if no overflow occurs. More...
 

Detailed Description

template<typename T>
struct Safe::Internal::fallback_add_overflow< T, typename enable_if<!is_signed< T >::VALUE >::type >

Overload of fallback_add_overflow for unsigned integers.

Member Function Documentation

§ add()

template<typename T >
static bool Safe::Internal::fallback_add_overflow< T, typename enable_if<!is_signed< T >::VALUE >::type >::add ( summand_1,
summand_2,
T &  result 
)
inlinestatic

Adds the two summands only if no overflow occurs.

This function performs a check if summand_1 + summand_2 would overflow and returns true in that case. If no overflow occurs, the sum is saved in result and false is returned.

Returns
true on overflow, false on no overflow

Further information: https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap


The documentation for this struct was generated from the following file: