I am trying to write a singleton class and I followed the standard template as below. But I get /usr/include/c++/7/ext/new_allocator.h:136:4: error: is private within this context { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
status_publisher.hpp
namespace test {
class StatusPublisher {
public:
static std::shared_ptr<StatusPublisher> getStatusPublisher();
private:
StatusPublisher();
static std::shared_ptr<StatusPublisher> instance_;
}
status_publisher.cpp
namespace test {
std::shared_ptr<StatusPublisher> StatusPublisher::getStatusPublisher() {
if(instance_.get()==nullptr) {
instance_ = std::make_shared<StatusPublisher>();
}
return instance_;
}
StatusPublisher::StatusPublisher() {
// Some code
}
}