3 $Date: 2010/03/11 14:42:04 $
8 * Copyright (c) 2001 by Peter Simons <simons@cryp.to>.
12 #ifndef RESETABLE_VARIABLE_H
13 #define RESETABLE_VARIABLE_H
15 // This is a wrapper class about variables where you want to keep
16 // track of whether it has been assigened yet or not.
26 RESETABLE() : value(), is_set(false) {}
28 RESETABLE(const RESETABLE<value_type> & rvalue)
29 : value(rvalue.value),
33 RESETABLE(const value_type& val) : value(val), is_set(true) {}
35 RESETABLE<value_type> & operator=(const RESETABLE<value_type> & rvalue)
38 is_set = rvalue.is_set;
42 RESETABLE<value_type> & operator=(const value_type& rhs)
49 const value_type & const_data() const throw() { return value; }
50 value_type & data() throw() { return value; }
51 operator const value_type&() const throw() { return value; }
52 bool res_empty() const throw() { return !is_set; }
53 void reset() throw() { is_set = false; }
61 std::ostream & operator<<(std::ostream & o, const RESETABLE<T> & v)
63 return o << v.const_data();
66 #endif // RESETABLE_VARIABLE_H