Could you please explain which assertion you mean?
Another thing I don't understand:

reinterpret_cast<internal::Object**>
                                              ^^^  why additional
pointer sematics is needed

When a handle is empty the overloaded operator '*' returns null
pointer value and reinterpret_cast converts it to null pointer value
of destination type.
Testing on Windows I don't get any problems when 'internal::Object*'
is used instead of 'internal::Object**'.

Best regards,
Evgeny Astigeevich

On Apr 1, 3:51 pm, Anton Muhin <[email protected]> wrote:
> Good day, Evgeny.
>
> No.  Handle just another level of indirection.  So this code checks if
> any of handles is empty (not referencing any objects) and if both are
> not it checks if they reference the same object.  Your variant would
> trigger an assertion if any of handles is empty.
>
> yours,
> anton.
>
>
>
> On Thu, Apr 1, 2010 at 3:47 PM, Evgeny Astigeevich <[email protected]> wrote:
> > Hi,
>
> > I'm trying to figure out the code of v8::Handle:
>
> >  template <class S> bool operator==(Handle<S> that) const {
> >    internal::Object** a =
> > reinterpret_cast<internal::Object**>(**this);
> >    internal::Object** b =
> > reinterpret_cast<internal::Object**>(*that);
> >    if (a == 0) return b == 0;
> >    if (b == 0) return false;
> >    return *a == *b;
> >  }
>
> > The overloaded operator '==' returns true when handles contain the
> > same value.
>
> > Why is it written in such a way? Is it a workaround of compiler bugs?
> > Does not the following code work:
>
> >  template <class S> bool operator==(Handle<S> that) const {
> >    return reinterpret_cast<internal::Object*>(**this) ==
> > reinterpret_cast<internal::Object*>(*that);
> >  }
>
> > Best regards,
> > Evgeny Astigeevich.
>
> > --
> > v8-dev mailing list
> > [email protected]
> >http://groups.google.com/group/v8-dev
>
> > To unsubscribe, reply using "remove me" as the subject.

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to