EQUAL(CXXLB)

Shore Programmer's Manual - 2 August 96

NAME

equal \- compare references for equality

SYNOPSIS

#include <ShoreApp.h>
int Ref<T>::operator==(const Ref<T> &ref) const;
int Ref<T>::operator!=(const Ref<T> &ref) const;

// For use with p == 0 only:
int Ref<T>::operator==(const T *p) const;
int Ref<T>::operator!=(const T *p) const;

    Ref<T>::operator int() const;

DESCRIPTION

These operators implement equality comparisons among refs. The first two forms indicate whether two Ref<T>s point to the same object. The second two forms indicate whether the ref points to the same object as the given virtual memory pointer. The final form returns 0 if the ref is nil, 1 otherwise.

EXAMPLE

Ref<Part> p1, p2;

if(p1 == p2) ...

if(p1 != 0) ...

if(p1) ...
The first if-statement succeeds if p1 and p2 point to the same part object. The second and third if-statements are equivalent, and they succeed if p1 is not a nil ref.

The forms of the equality operator that take a virtual memory pointer are only intended for use with a parameter of 0.

In the current release of Shore, it is safe to compare refs whose targets have been destroyed. But in general, this practice is discouraged, as it may not be supported in future Shore releases.

VERSION

This manual page applies to Version 1.0 of theShore software.

SPONSORSHIP

The Shore project is sponsored by the Advanced Research Project Agency, ARPA order number 018 (formerly 8230), monitored by the U.S. Army Research Laboratory under contract DAAB07-92-C-Q508.

COPYRIGHT

Copyright (c) 1994, 1995, 1996 Computer Sciences Department, University of Wisconsin -- Madison. All Rights Reserved.

SEE ALSO

ref(cxxlb) , assign(cxxlb) , construct(cxxlb) .