[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0af7b60 2/4: Initialize ValueInterval members
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0af7b60 2/4: Initialize ValueInterval members in declaration; default the ctor (VZ) |
Date: |
Mon, 13 Feb 2017 17:57:38 -0500 (EST) |
branch: master
commit 0af7b6055097a7ef091034c54a04d0a34fc20f02
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Initialize ValueInterval members in declaration; default the ctor (VZ)
See:
http://lists.nongnu.org/archive/html/lmi/2017-02/msg00044.html
Changed two default values, so that a default-constructed instance
applies a default value in [e_inception, e_maturity). In practice,
most input sequences comprise only one interval, which is necessarily
this (new) default.
Incidentally improved this struct's documentation.
---
input_sequence.cpp | 10 ----------
input_sequence.hpp | 25 +++++++++++++------------
2 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 957e705..a043c34 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -40,16 +40,6 @@
#include <stdexcept>
#include <type_traits>
-ValueInterval::ValueInterval()
- :value_number (0.0)
- ,value_is_keyword (false)
- ,begin_duration (0)
- ,begin_mode (e_duration)
- ,end_duration (0)
- ,end_mode (e_duration)
- ,insane (false)
-{}
-
SequenceParser::SequenceParser
(std::string const& input_expression
,int a_years_to_maturity
diff --git a/input_sequence.hpp b/input_sequence.hpp
index cc10a54..f997b31 100644
--- a/input_sequence.hpp
+++ b/input_sequence.hpp
@@ -150,22 +150,23 @@ enum duration_mode
,e_maturity
};
-// value applies throughout the interval [begin_duration, end_duration).
-// where value means value_keyword if value_is_keyword, else value_number
-// 'insane' flags instances that are syntactically valid but semantically
-// invalid, such as improper intervals e.g. [5, 3).
+/// A single 'span' in the input-sequence grammar.
+///
+/// value_{number,keyword} applies throughout the interval
+/// [begin_duration, end_duration)
+
struct ValueInterval
{
- ValueInterval();
+ ValueInterval() = default;
- double value_number;
+ double value_number = 0.0;
std::string value_keyword;
- bool value_is_keyword;
- int begin_duration;
- duration_mode begin_mode;
- int end_duration;
- duration_mode end_mode;
- bool insane;
+ bool value_is_keyword = false;
+ int begin_duration = 0;
+ duration_mode begin_mode = e_inception;
+ int end_duration = 0;
+ duration_mode end_mode = e_maturity;
+ bool insane = false;
};
class SequenceParser