C++?ж??????Singleton????Щ???
???????????? ???????[ 2015/3/11 15:34:30 ] ????????C++ ??? ???????
????local static
???????????д??????????main????????????getInstance?????????????????main???????????????
??????????????е???????????????????local static??????C++?????????????local static?????????????????????????????????????????????????
template<typename T>
class Singleton
{
private:
Singleton();
~Singleton();
class Creater
{
public:
Creater()
: value_(new T())
{
}
~Creater()
{
delete value_;
value_ = NULL;
}
T& getValue()
{
return *value_;
}
T* value_;
};
public:
static T& getInstance()
{
static Creater creater;
return creater.getValue();
}
private:
class Dummy
{
public:
Dummy()
{
Singleton<T>::getInstance();
}
};
static Dummy dummy_;
};
template<typename T>
typename Singleton<T>::Dummy Singleton<T>::dummy_;
???????????????dummy_????????????main????????е???getInstance????????????????????????????main?????????????Singleton???????????????????main???????????????г????????????????
???????????????????main?????????????????????????2????????????
?????????????????????????д???У????Щ??????main?????????á????Щ??????main???????????????????????main??????????????????2?????????????????????д????????????????????????????????????????ò???????main?????????Singleton????????????е??????????????staitc member????C++???????static member?????main????????????????????????????static member????????????δ?????? ?????????main??????getInstance??????п?????????Singleton??static member????г???????????????
?????????????main?????Singleton???????????main???????????????????????????£?????????????????д?????C++ 11?μ?Meyers Singleton????????g++ 4.0????????汾???????????????????????????μ?C++ 03????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????