I'm not sure, if I something misunderstand, but I'm woriing about security making only one instace of singleton. (I have readed Modern programing in c++)
I can make a any number of them:
#include "Singleton.h"
class ExperimentClass
{
private:
ExperimentClass();
~ExperimentClass();
ExperimentClass(ExperimentClass&);
ExperimentClass& operator=(ExperimentClass&);
friend class Loki::CreateUsingNew<ExperimentClass>;
No way to handle your question if you add some friend classes or functions into your own classes.
But you told me there was no perfect solution,Loki just helped close to our goals.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
- If I will not add friend, Loki's singleton holder will not be able to create any instance, if I understand it correctly, so I have to.
- I see. Ok ;).
Thanks for answer and sorry for late reply, it looks like I failed to set up monitoring this thread correctly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure, if I something misunderstand, but I'm woriing about security making only one instace of singleton. (I have readed Modern programing in c++)
I can make a any number of them:
#include "Singleton.h"
class ExperimentClass
{
private:
ExperimentClass();
~ExperimentClass();
ExperimentClass(ExperimentClass&);
ExperimentClass& operator=(ExperimentClass&);
friend class Loki::CreateUsingNew<ExperimentClass>;
public:
// ...
};
typedef Loki::SingletonHolder<ExperimentClass, Loki::CreateUsingNew> ExperimentClassSingleton;
void Experiment()
{
ExperimentClass &instance1 = ExperimentClassSingleton::Instance();
ExperimentClass *instance2 = Loki::CreateUsingNew<ExperimentClass>::Create();
}
I'm sorry, I send it to "OpenDiscussion", not "Developers". Can I or Admin move it to the right place?
No way to handle your question if you add some friend classes or functions into your own classes.
But you told me there was no perfect solution,Loki just helped close to our goals.
- If I will not add friend, Loki's singleton holder will not be able to create any instance, if I understand it correctly, so I have to.
- I see. Ok ;).
Thanks for answer and sorry for late reply, it looks like I failed to set up monitoring this thread correctly.