#include <cstdio>
#include <cstdlib>
class CThing
{
private:
int m_iVar;
public:
CThing(int iInput = 0)
: m_iVar(iInput)
{
}
// Branchy code
void Process(bool bIncrementAfter)
{
printf("%d\n", m_iVar);
if (bIncrementAfter)
++m_iVar;
}
// Branchless code
template <bool t_bIncrementAfter>
void Process()
{
printf("%d\n", m_iVar);
if (t_bIncrementAfter)
++m_iVar;
}
int GetVar() const { return m_iVar; }
};
void main()
{
CThing a(10);
a.Process((rand() % 2) == 1); // Using rand() to force compiler to support both true and false
a.Process<true>();
printf("%d\n", a.GetVar());
}