From c8b080defffe28f5fc1aa39447a467d8f7b7ee5c Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Mon, 7 Oct 2013 23:25:25 +0300 Subject: [PATCH 1/1] Small refactoring in RESETABLE. --- include/stg/resetable.h | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/include/stg/resetable.h b/include/stg/resetable.h index f3cecac8..c78d0247 100644 --- a/include/stg/resetable.h +++ b/include/stg/resetable.h @@ -1,9 +1,3 @@ - /* - $Revision: 1.9 $ - $Date: 2010/03/11 14:42:04 $ - $Author: faust $ - */ - /* * Copyright (c) 2001 by Peter Simons . * All rights reserved. @@ -15,8 +9,6 @@ // This is a wrapper class about variables where you want to keep // track of whether it has been assigened yet or not. -#include - template class RESETABLE { @@ -24,32 +16,31 @@ public: typedef T value_type; RESETABLE() : value(), is_set(false) {} + RESETABLE(const T & v) : value(v), is_set(true) {} - RESETABLE(const RESETABLE & rvalue) + RESETABLE(const RESETABLE & rvalue) : value(rvalue.value), is_set(rvalue.is_set) {} - RESETABLE(const value_type& val) : value(val), is_set(true) {} - - RESETABLE & operator=(const RESETABLE & rvalue) + RESETABLE & operator=(const RESETABLE & rhs) { - value = rvalue.value; - is_set = rvalue.is_set; + value = rhs.value; + is_set = rhs.is_set; return *this; } - RESETABLE & operator=(const value_type& rhs) + RESETABLE & operator=(const T & rhs) { value = rhs; is_set = true; return *this; } - const value_type & const_data() const throw() { return value; } - value_type & data() throw() { return value; } - operator const value_type&() const throw() { return value; } - bool res_empty() const throw() { return !is_set; } + const T & const_data() const throw() { return value; } + T & data() throw() { return value; } + const T & data() const throw() { return value; } + bool empty() const throw() { return !is_set; } void reset() throw() { is_set = false; } private: @@ -57,14 +48,4 @@ private: bool is_set; }; -template -std::ostream & operator<<(std::ostream & o, const RESETABLE & v); - -template -inline -std::ostream & operator<<(std::ostream & o, const RESETABLE & v) -{ - return o << v.const_data(); -} - #endif // RESETABLE_VARIABLE_H -- 2.44.2