MCPcopy Create free account
hub / github.com/Taywee/args / SafeMultiply

Function SafeMultiply

test_join_debug.cpp:24–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23 template<typename T>
24 bool SafeMultiply(T a, T b, T& out)
25 {
26 if (a == 0 || b == 0)
27 {
28 out = 0;
29 return true;
30 }
31
32 if (std::is_unsigned<T>::value || true)
33 {
34 if (b > std::numeric_limits<T>::max() / a)
35 {
36 return false;
37 }
38 }
39 out = a * b;
40 return true;
41 }
42
43 namespace detail
44 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected