1
0
forked from boostorg/core
Files
boost_core/doc/addressof.qbk

44 lines
806 B
Plaintext
Raw Normal View History

[section:addressof addressof]
[section Authors]
* Brad King
* Douglas Gregor
* Peter Dimov
[endsect]
[section Header <boost/core/addressof.hpp>]
The header `<boost/core/addressof.hpp>` defines the function
template `boost::addressof`. `boost::addressof(x)` returns the
address of `x`. Ordinarily, this address can be obtained by
`&x`, but the unary `&` operator can be overloaded.
`boost::addressof` was originally contributed by Brad King
based on ideas from discussion with Doug Gregor.
[endsect]
[section Example]
``
#include <boost/core/addressof.hpp>
struct useless_type { };
class nonaddressable {
useless_type operator&() const;
};
void f() {
nonaddressable x;
nonaddressable* xp = boost::addressof(x);
// nonaddressable* xpe = &x; /* error */
}
``
[endsect]
[endsect]