Do I need a singleton here? Or can I use std::move
I am developing a font class for my opengl graphics library and I came
across a quandry. I have a font which is simply a value for font id and
wrapper code to load the font and kill it. Works fine, then I notice I
don't have a virtual destructor, nor any destructor at all. So I throw in a
virtual destructor and call the code to unload the glfont. I run the
program, now no fonts are visible.
The problem is that my fonts are stored in a map by font name and the font,
and of course std::maps along with most containers use copy.
I've been bitten by this before and wound up using pointers so I could
control when the destructor was called. This was okay since polymophism was
involved and I needed pointers anyway.
I thought about using some variant of a smart pointer but I would still be
working with pointer logic.
My next idea was to use some variant of the singlton pattern which in
implementation I wouldn't be using it more than a smart pointer anyway.
I have heard somethign about std::move being in 0x and that std::vector and
other containers were supposed to use std::move instead of copy. But if
that was the case I wouldn't be having this problem.
Any suggestions? I am willing to use any feature of 0x that Express 2010
uses.