diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-26 23:56:43 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-26 23:56:43 +0900 |
| commit | da7400ef5c62ee144fc14ba7ca4745349f0b0c72 (patch) | |
| tree | b0d023eecfcfcca2a88eb3466baf878bdff9f4c1 /src/SingletonHolder.h | |
| parent | 47402c5f29cb806f73aae2ed18aa2dde21956700 (diff) | |
Return std::unique_ptr member as const ref
Returning raw pointer has a risk that it may be stolen by
std::shared_ptr in accident.
Diffstat (limited to 'src/SingletonHolder.h')
| -rw-r--r-- | src/SingletonHolder.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/SingletonHolder.h b/src/SingletonHolder.h index e37cc4ac..19f4e6c9 100644 --- a/src/SingletonHolder.h +++ b/src/SingletonHolder.h @@ -50,9 +50,9 @@ private: public: ~SingletonHolder() {} - static T* instance() + static std::unique_ptr<T>& instance() { - return instance_.get(); + return instance_; } static void instance(std::unique_ptr<T> ptr) |
