Ray's playground

 

boost::addressof

#include <iostream>
#include 
<boost/utility.hpp>
using namespace std;

class Object
{
public:
    
int i;
    Object():i(
0x11223344){}
    
int operator&()
    {
        
return 0;
    }
};

int main()
{
    Object obj;
    cout 
<< &obj << endl;
    Object 
*= boost::addressof(obj);
    Object 
*p1 = std::addressof(obj);
    cout 
<< p << endl;
    cout 
<< p1 << endl;
    cout 
<< hex << p-><< endl;
    cout 
<< hex << p1-><< endl;
    cin.
get();
}

posted on 2011-03-14 22:53  Ray Z  阅读(374)  评论(0编辑  收藏  举报

导航