| Jon Stewart on 18 Jun 2003 21:02:01 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| [ALACPP] Singleton clarification |
In the Singletons chapter, Alexandrescu points out that you must make
SingletonHolder a friend of your singleton type if you are taking the
normal precautions of privatizing your type's constructors; he doesn't
show any example code, however. I tried this, and got some compiler
errors.
To use Loki's SingletonHolder, you need to make your chosen CreationPolicy
a friend of your type, NOT SingletonHolder. E.g.:
class Foo {
friend struct Loki::CreateUsingNew< Foo >;
};
I think Singleton is possibly the easiest to use component of Loki;
singletons present themselves all the time and there's no excuse not to
have Loki handle the mess for you.
Jon
--
Jon Stewart
stew1@xxxxxxxxxxx
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp