$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2003-12-03 14:25:08
On Wed, 3 Dec 2003, Rob Stewart wrote:
> From: Douglas Paul Gregor <gregod_at_[hidden]>
> Here's the context for what you're proposing. It's code that
> Dave posted in an earlier message.
>
> template <class T>
> struct bool_testable
> {
> private:
> struct impl { int x; };
> typedef int impl::*safe_bool;
> public:
> operator safe_bool() const
> {
> return !*static_cast<T const*>(this) ? 0 : &impl::x;
> }
> };
>
> I'm clearly missing something. How can there be an address for
> impl::x if there's no instance of impl?
Member data pointers are nothing more than glorified offsets. &impl::x
essentially represents the offset of "x" from the start of any given
"impl" object.
Doug