Review Board 2.0.15

base: Use constexpr in Cycles

Review Request #2889 - Created June 16, 2015 and submitted

Andreas Sandberg
Changeset 10874:f927a77a299c
base: Use constexpr in Cycles

Declare the constructor and all of the operators that don't change the
state of a Cycles instance as constexpr. This makes it possible to use
Cycles as a static constant and allows the compiler to evaulate simple
expressions at compile time. An unfortunate side-effect of this is
that we cannot use assertions since C++11 doesn't support them in
constexpr functions. As a workaround, we throw an invalid_argument
exception when the assert would have triggered. A nice side-effect of
this is that the compiler will evaluate the "assertion" at compile
time when an expression involving Cycles can be statically evaluated.

Review request changed
Updated (Aug. 7, 2015, 2:01 a.m.)

Status: Closed (submitted)