]> git.stg.codes - stg.git/blobdiff - include/stg/resetable.h
Fixed compilation with linux-3.5.1 and higher.
[stg.git] / include / stg / resetable.h
index d31bffda739146d324b865c468fdee714f99d7ce..f3cecac843b65ba94f85ffc023f945e7c8981c64 100644 (file)
 
 #include <iostream>
 
 
 #include <iostream>
 
-template <typename varT>
+template <typename T>
 class RESETABLE
 {
 class RESETABLE
 {
-    template <typename varT1>
-    friend std::ostream & operator<<(std::ostream & o, RESETABLE<varT1> v);
 public:
 public:
-    typedef varT value_type;
+    typedef T value_type;
 
 
-    //-------------------------------------------------------------------------
-    RESETABLE()
-        : value(),
-          is_set(false)
-    {
-    }
-    //-------------------------------------------------------------------------
-    RESETABLE<value_type>(const RESETABLE<value_type> & rvalue)
+    RESETABLE() : value(), is_set(false) {}
+
+    RESETABLE(const RESETABLE<value_type> & rvalue)
         : value(rvalue.value),
           is_set(rvalue.is_set)
         : 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<value_type> & operator=(const RESETABLE<value_type> & rvalue)
     {
         value = rvalue.value;
         is_set = rvalue.is_set;
         return *this;
     }
     RESETABLE<value_type> & operator=(const RESETABLE<value_type> & rvalue)
     {
         value = rvalue.value;
         is_set = rvalue.is_set;
         return *this;
     }
-    //-------------------------------------------------------------------------
-    RESETABLE<value_type> & operator= (const value_type& rhs)
+
+    RESETABLE<value_type> & operator=(const value_type& rhs)
     {
         value = rhs;
         is_set = true;
         return *this;
     }
     {
         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 <typename varT>
-std::ostream & operator<<(std::ostream & o, RESETABLE<varT> v)
+
+template <typename T>
+std::ostream & operator<<(std::ostream & o, const RESETABLE<T> & v);
+
+template <typename T>
+inline
+std::ostream & operator<<(std::ostream & o, const RESETABLE<T> & v)
 {
 {
-    return o << v.value;
+    return o << v.const_data();
 }
 }
-//-------------------------------------------------------------------------
-#endif // RESETABLE_VARIABLE_H
 
 
+#endif // RESETABLE_VARIABLE_H