From a1b28d756fe52a53d9d4da4d23853969fd529115 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 23 Oct 2012 14:40:38 +1100 Subject: Make the recursive solver work properly. If you ignore the intermediate results for the strategy iteration phase then you're in the clear! I think! --- impl/Complete.hpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'impl/Complete.hpp') diff --git a/impl/Complete.hpp b/impl/Complete.hpp index 8c5559a..38b637e 100644 --- a/impl/Complete.hpp +++ b/impl/Complete.hpp @@ -7,23 +7,38 @@ template T infinity() { } +template +T unknown(const T&) { } template struct Complete { Complete() - : _value(0), _infinity(false) { } + : _value(0), _infinity(false), _unknown(false) { } Complete(const T& value) - : _value(value), _infinity(false) { } + : _value(value), _infinity(false), _unknown(false) { } Complete(const T& value, const bool& infinity) - : _value(value), _infinity(infinity) { + : _value(value), _infinity(infinity), _unknown(false) { assert(value != 0 || infinity == false); } Complete(const Complete& other) - : _value(other._value), _infinity(other._infinity) { } + : _value(other._value), _infinity(other._infinity), _unknown(other._unknown) { } + Complete(const Complete& other, bool unknown) + : _value(other._value), _infinity(other._infinity), _unknown(unknown) { } + + Complete asUnknown() const { + return Complete(*this, true); + } + Complete asKnown() const { + return Complete(*this, false); + } + bool isUnknown() const { + return _unknown; + } Complete& operator=(const Complete& other) { _value = other._value; _infinity = other._infinity; + _unknown = other._unknown; return *this; } Complete& operator+=(const Complete& other) { @@ -98,6 +113,7 @@ struct Complete { private: T _value; bool _infinity; + bool _unknown; }; template @@ -110,6 +126,8 @@ std::istream& operator>>(std::istream& cin, Complete& num) { template std::ostream& operator<<(std::ostream& cout, const Complete& num) { + if (num._unknown) + cout << "(unknown)"; if (num._infinity) { cout << (num._value > 0 ? "inf" : "-inf"); } else { @@ -122,5 +140,9 @@ template<> Complete infinity() { return Complete(1, true); } +template<> +Complete unknown(const Complete& x) { + return Complete(x, true); +} #endif -- cgit v1.2.3