Boost 싱글톤 Example

2015. 2. 12. 14:03C++

Boost 싱글톤 Example

http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/singleton.html


#pragma once

#include <boost/serialization/singleton.hpp>

#include "ted_base.h"


class BoostSingleTon : public boost::serialization::singleton<BoostSingleTon>

{

friend class boost::serialization::singleton<BoostSingleTon>;

public:

BoostSingleTon(void);

~BoostSingleTon(void);


public:

static BoostSingleTon& get() {

return boost::serialization::singleton<BoostSingleTon>::get_mutable_instance();

}

int32 test;

};

호출하기

int _tmain(int argc, _TCHAR* argv[])

{

BoostSingleTon::get().test = 5;

LOG_DEBUG<<"싱글톤 테스트 ="<<BoostSingleTon::get().test;

system("pause");

return 0;

}