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.
© 2002-2025 Kirit & Tai Sælensminde. All forum posts are copyright their respective authors.
Licensed under a Creative Commons License. Non-commercial use is fine so long as you provide attribution.