Skip to content

Commit

Permalink
Return the newly created object from initialize() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe Corbelli committed Oct 12, 2017
1 parent e8079ed commit 2a60e93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/Singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ class Singleton
typedef T derived_type;

template<typename... Args>
static inline void initialize(Args& ... args)
static inline T& initialize(const Args& ... args)
{
derived_type* p(new derived_type(args...));
instance.reset(p);
atomic_rtlogger.store(p, std::memory_order_seq_cst);
return *p;
}
static inline void destroy() { instance.reset(); }
static inline T& get() { return *instance; }
Expand Down

0 comments on commit 2a60e93

Please sign in to comment.