Default Initialize ExpressionRef to Zero

The default constructor of ExpressionRef now creates a compile
time constant zero assignment. This patch is required, because
a reason change in Jet assumes default 0 initialization.

Change-Id: I8185cef587c17ab828896bce1e768170f8229d4e
This commit is contained in:
Darius Rueckert
2020-03-09 15:15:55 +01:00
parent bf1aff2f0e
commit 9049688c60
4 changed files with 20 additions and 19 deletions
@@ -46,7 +46,7 @@ namespace internal {
//
// ExpressionRef should be passed by value.
struct ExpressionRef {
ExpressionRef() = default;
ExpressionRef() : ExpressionRef(0.0) {}
// Create a compile time constant expression directly from a double value.
// This is important so that we can write T(3.14) in our code and
@@ -57,6 +57,10 @@ struct ExpressionRef {
// must work for T = Jet<ExpressionRef>.
ExpressionRef(double compile_time_constant);
// Adds the expression to the active graph and initializes this ExpressionRef
// accordingly.
ExpressionRef(const Expression& expression);
// By adding this deleted constructor we can detect invalid usage of
// ExpressionRef. ExpressionRef must only be created from constexpr doubles.
//
@@ -97,8 +101,6 @@ struct ExpressionRef {
// The index into the ExpressionGraph data array.
ExpressionId id = kInvalidExpressionId;
static ExpressionRef Create(ExpressionId id);
};
// A helper function which calls 'InsertBack' on the currently active graph.