$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Hamish Mackenzie (boost_at_[hidden])
Date: 2002-01-28 10:13:03
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 >
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 );
}