A simple meta-accessor

Created 2007-07-26T11:42:25.090Z, last edited 2007-07-26T12:11:04.606Z

Here is a very minimal class that can be used to wrap an attribute so that syntactically it will behave as if it has accessors.

template< typename T >
class Accessors {
private:
	T m_t;
public:
	Accessors() {}
	Accessors( const T &t ) : m_t( t ) {}

	const T &operator() () const { return m_t; }
	void operator() ( const T &t ) { m_t = t; }
};

This is the absolute simplest implementation that I can think of and should be a good starting point.