Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-01-24 11:42:46


--- At Thu, 24 Jan 2002 15:05:24 +0200, Peter Dimov wrote:

>int main()
>{
> obj_container c;
> std::for_each( c.begin(), c.end(), boost::mem_fn( &obj::method ) );
>}
>
>&obj::method is actually of type void (obj_base::*) (), and while mem_fn
>recognizes references to the 'base' type (obj_base&), it cannot tell whether
>obj& is a smart pointer or an object reference.
>
>I can probably fix this by using boost::is_convertible<U, T> but
>unfortunately it's known to break some compilers. Food for thought. Thanks
>for the bug report. :-)

Thank you for the explaination Peter. Your change was a translation
problem on my part. Apologies.

Is there an appropriate work around? I have been using:

namespace boost
{
  inline obj* get_pointer( obj & p ) { return &p; }
}

As this was the source of the compiler error. Is there a better work
around? I am leary of a full template replacement for this because I dont
know what the side affects would be:

namespace boost
{
  template < class T >
  inline T* get_pointer( T & r ) { return &r; }
}

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net