git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b98e2fd
)
Small refactoring in RESETABLE.
author
Maxim Mamontov
<faust.madf@gmail.com>
Mon, 7 Oct 2013 20:25:25 +0000
(23:25 +0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Mon, 7 Oct 2013 20:25:25 +0000
(23:25 +0300)
include/stg/resetable.h
patch
|
blob
|
history
diff --git
a/include/stg/resetable.h
b/include/stg/resetable.h
index f3cecac843b65ba94f85ffc023f945e7c8981c64..c78d02476e5cbea97d9b80acd764a80aad8d1c61 100644
(file)
--- 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 <simons@cryp.to>.
* All rights reserved.
/*
* Copyright (c) 2001 by Peter Simons <simons@cryp.to>.
* 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.
// This is a wrapper class about variables where you want to keep
// track of whether it has been assigened yet or not.
-#include <iostream>
-
template <typename T>
class RESETABLE
{
template <typename T>
class RESETABLE
{
@@
-24,32
+16,31
@@
public:
typedef T value_type;
RESETABLE() : value(), is_set(false) {}
typedef T value_type;
RESETABLE() : value(), is_set(false) {}
+ RESETABLE(const T & v) : value(v), is_set(true) {}
- RESETABLE(const RESETABLE<
value_type
> & rvalue)
+ RESETABLE(const RESETABLE<
T
> & 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<value_type> & operator=(const RESETABLE<value_type> & rvalue)
+ RESETABLE<T> & operator=(const RESETABLE<T> & rhs)
{
{
- value = r
value
.value;
- is_set = r
value
.is_set;
+ value = r
hs
.value;
+ is_set = r
hs
.is_set;
return *this;
}
return *this;
}
- RESETABLE<
value_type> & operator=(const value_type
& rhs)
+ RESETABLE<
T> & operator=(const T
& 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; }
+ 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:
void reset() throw() { is_set = false; }
private:
@@
-57,14
+48,4
@@
private:
bool is_set;
};
bool is_set;
};
-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.const_data();
-}
-
#endif // RESETABLE_VARIABLE_H
#endif // RESETABLE_VARIABLE_H