Talk:Qt thread-safe singleton

From Qt Wiki
Jump to navigation Jump to search

(not sure if this is the right place for comments)

With the newest update to this page (Dec 2016) https://wiki.qt.io/index.php?title=Qt_thread-safe_singleton&oldid=29503 , I cannot compile the code. Basically, when I call

Singleton<Origo>::Instance(MyClass::CreateInstance)

I get:

../app/include/app/Singleton.h:38:29: error: cannot initialize a parameter of type 'Type' (aka 'void *(*)()') with an lvalue of type 'CreateInstanceFunction' (aka 'MyClass *(*)()'): different return type ('void *' vs 'MyClass *')
    Singleton::create.store(create);

I THINK the fix for this is to change the declaration of create to:

static QBasicAtomicPointer<T* (void)> create;

(and same with the template instantiation at the end)

Does this make sense?

Original version?

Is there a way to see the original content of this page? I'm assuming the info was moved somewhere, but I can't find it?

The content was deleted in December 2018 because a team of documentation contributors reviewed the code and found it to be excessively convoluted. --JKSH (talk) 10:40, 3 February 2019 (UTC)