2 Copyright 2014 Peter Dimov
4 Distributed under the Boost Software License, Version 1.0.
6 See accompanying file LICENSE_1_0.txt
7 or copy at http://boost.org/LICENSE_1_0.txt
10 [section:addressof addressof]
20 [section Header <boost/core/addressof.hpp>]
22 The header `<boost/core/addressof.hpp>` defines the function
23 template `boost::addressof`. `boost::addressof(x)` returns the
24 address of `x`. Ordinarily, this address can be obtained by
25 `&x`, but the unary `&` operator can be overloaded. `boost::addressof`
26 avoids calling used-defined `operator&()`.
28 `boost::addressof` was originally contributed by Brad King
29 based on ideas from discussion with Doug Gregor.
36 template<class T> T* addressof( T& x );
45 #include <boost/core/addressof.hpp>
47 struct useless_type { };
49 class nonaddressable {
50 useless_type operator&() const;
55 nonaddressable* xp = boost::addressof(x);
56 // nonaddressable* xpe = &x; /* error */