summaryrefslogtreecommitdiff
path: root/impl/Complete.hpp
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@carlo-laptop>2012-10-30 20:56:38 +1100
committerCarlo Zancanaro <carlo@carlo-laptop>2012-10-30 20:56:38 +1100
commit6a4786bde976e9a023c7f65a395384d214c5102c (patch)
treef3dd303f21dfa0be269a932dd05438041a290f27 /impl/Complete.hpp
parentff2030f3a19926334fbe3a043c5f88622c17c2f8 (diff)
parent95b82ea3830c3a34455323167894647e3aa773a6 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Conflicts: impl/test/run
Diffstat (limited to 'impl/Complete.hpp')
-rw-r--r--impl/Complete.hpp30
1 files changed, 4 insertions, 26 deletions
diff --git a/impl/Complete.hpp b/impl/Complete.hpp
index 336ab24..e3ec15a 100644
--- a/impl/Complete.hpp
+++ b/impl/Complete.hpp
@@ -7,38 +7,23 @@
template<typename T>
T infinity() { }
-template<typename T>
-T unknown(const T&) { }
template<typename T>
struct Complete {
Complete()
- : _value(0), _infinity(false), _unknown(false) { }
+ : _value(0), _infinity(false) { }
Complete(const T& value)
- : _value(value), _infinity(false), _unknown(false) { }
+ : _value(value), _infinity(false) { }
Complete(const T& value, const bool& infinity)
- : _value(value), _infinity(infinity), _unknown(false) {
+ : _value(value), _infinity(infinity) {
assert(value != 0 || infinity == false);
}
Complete(const Complete& other)
- : _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;
- }
+ : _value(other._value), _infinity(other._infinity) { }
Complete& operator=(const Complete& other) {
_value = other._value;
_infinity = other._infinity;
- _unknown = other._unknown;
return *this;
}
Complete& operator+=(const Complete& other) {
@@ -117,7 +102,6 @@ struct Complete {
private:
T _value;
bool _infinity;
- bool _unknown;
};
template<typename Z>
@@ -130,8 +114,6 @@ std::istream& operator>>(std::istream& cin, Complete<Z>& num) {
template<typename Z>
std::ostream& operator<<(std::ostream& cout, const Complete<Z>& num) {
- if (num._unknown)
- cout << "(unknown)";
if (num._infinity) {
cout << (num._value > 0 ? "inf" : "-inf");
} else {
@@ -144,9 +126,5 @@ template<>
Complete<int> infinity() {
return Complete<int>(1, true);
}
-template<>
-Complete<int> unknown(const Complete<int>& x) {
- return Complete<int>(x, true);
-}
#endif