Boost logo

Boost :

From: Hamish Mackenzie (boost_at_[hidden])
Date: 2002-01-28 12:30:11


On Mon, 2002-01-28 at 15:13, Hamish Mackenzie wrote:
> I am writing some code that uses a C based API (Microsoft's MAPI) and it
> would be handy to have mem_var_* classes to access members of structures
> without having to write helper functions. Do these exist already?
>
> Something like....
>
> template< Class_Type >

oops should be
template< class Class_Type, class Member_Type >

> class const_mem_var_ref_t : public
> std::unary_function< Class_Type, Member_Type >
> {
> public:
> explicit const_mem_var_ref_t( Member_Type Class_Type::* ptr )
> : ptr_( ptr ) {}
>
> const Member_Type &operator()( const Class_Type &x ) const
> {
> return x.*ptr_;
> }
>
> private:
> Member_Type Class_Type::* ptr_;
> };
>
> template< class Class_Type, class Member_Type >
> const_mem_var_ref_t< Class_Type, Member_Type >
> const_mem_var_ref( Member_Type Class_Type::* ptr )
> {
> return const_mem_var_ref_t< Class_Type, Member_Type >( ptr );
> }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk