From: Maxim Mamontov Date: Wed, 14 Sep 2011 13:34:29 +0000 (+0300) Subject: Stylistic changes in RESETABLE X-Git-Tag: 2.408-rc1~65 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/23f1d41b58009a05cdea03d3ea02739a9a9dfeea?ds=sidebyside Stylistic changes in RESETABLE --- diff --git a/include/stg/resetable.h b/include/stg/resetable.h index d31bffda..cb35d808 100644 --- a/include/stg/resetable.h +++ b/include/stg/resetable.h @@ -17,82 +17,50 @@ #include -template +template class RESETABLE { - template - friend std::ostream & operator<<(std::ostream & o, RESETABLE v); public: - typedef varT value_type; + typedef T value_type; - //------------------------------------------------------------------------- - RESETABLE() - : value(), - is_set(false) - { - } - //------------------------------------------------------------------------- - RESETABLE(const RESETABLE & rvalue) + RESETABLE() : value(), is_set(false) {} + + RESETABLE(const RESETABLE & rvalue) : value(rvalue.value), is_set(rvalue.is_set) - { - } - //------------------------------------------------------------------------- - RESETABLE(const value_type& val) - : value(val), - is_set(true) - { - } - //------------------------------------------------------------------------- + {} + + RESETABLE(const value_type& val) : value(val), is_set(true) {} + RESETABLE & operator=(const RESETABLE & rvalue) { value = rvalue.value; is_set = rvalue.is_set; return *this; } - //------------------------------------------------------------------------- - RESETABLE & operator= (const value_type& rhs) + + RESETABLE & operator=(const value_type& 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; - } - //------------------------------------------------------------------------- - void reset() throw() - { - is_set = false; - } - //------------------------------------------------------------------------- -protected: - value_type value; - bool is_set; + + 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; } + void reset() throw() { is_set = false; } + +private: + value_type value; + bool is_set; }; -//----------------------------------------------------------------------------- -template -std::ostream & operator<<(std::ostream & o, RESETABLE v) + +template +std::ostream & operator<<(std::ostream & o, const RESETABLE & v) { - return o << v.value; + return o << v.const_data(); } -//------------------------------------------------------------------------- -#endif // RESETABLE_VARIABLE_H +#endif // RESETABLE_VARIABLE_H