The ext::accessor is a templated wrapper that is used when one needs a lightweight mapping of reading a member variable to a non-static member function call.
The ext::accessor provides a syntactic conversion of calling a member function into accessing a member variable. Whether every access to the variable is interpreted as a call to the function or the value is cached controls the Policy parameter.
For full mapping (with write access) see ext::vartor template.
            template <typename T, typename C, T (C::* F) () const,
                     
            ext::policy::type Policy = ext::policy::none>
            class ext::accessor {
                public:
                    explicit accessor (const C *);
                    operator  T () const;
            
                    void  invalidate ();
                // only when instantiated with ext::policy::cached
            };
        
        
            #include <ext/c++>
            #include <windows.h>
            
            class C {
                private:
                    int get_info () { /* ... */ };
            
                public:
                    const ext::accessor <int, C, &C::get_info> info;
            
                public:
                    C () : info (this) {};
            };
            
            int main () {
                C c;
                // ...
                int i = c.info; // calls C::get_info
                // ...
            };
        
        
        The ext::accessor members can provide simple to use interface to variables whose value can be obtained only by calling a function (like API functions).
[index]