MCPcopy Create free account
hub / github.com/dcleblanc/SafeInt / CompiledMixedType

Function CompiledMixedType

Test/CompileTest.cpp:32–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31template <typename T, typename U>
32void CompiledMixedType()
33{
34 // Mixed constructors
35 U u = 0;
36 T t = 0;
37 bool b = false;
38 SafeInt<T> st(u);
39 SafeInt<U> su(u);
40 SafeInt<T> st2(su);
41
42 // Shut up the compiler
43 b = !b;
44
45 // Assignment
46 st = t;
47 st = u;
48 st = su;
49 st = st2;
50
51 // Casting
52 U u2 = (U)st;
53
54 // Multiplication
55 t = st * u;
56 t = st * st2;
57 t = u * st;
58 st *= u;
59 st *= su;
60
61 // Modulus, modulus assignment
62 u = 1;
63 st = 1;
64 su = 1;
65 // For some reason, this is annoying the VS17 link time code generation
66// t = u % st;
67
68 t = st % u;
69 st2 = 1;
70 t = st % st2;
71 st %= u;
72 st %= su;
73
74 // Division
75 u = 1;
76 st2 = 1;
77 st = 1;
78 t = st / u;
79 t = st / st2;
80 t = u / st;
81 st /= u;
82 st /= su;
83
84 // Addition
85 t = st + u;
86 t = st + st2;
87 t = u + st;
88 st += u;
89 st += su;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected