Using the Singleton patterns from:
C++ Singleton design pattern and http://www.yolinux.com/TUTORIALS/C++Singleton.html
I have made a specialized Singleton class rather than using one of the hidden ones e.g. Boost::Serialization::Singleton.
How Can I alias the singleton call though? It's quite irksome to have to write
namespace::class::get_instance().method()
everywhere
specifically how can i alias the namespace::class::get_instance()
part of it?
Specifically I would like to be able to do this on the stack rather than the heap since the public constructor, copy constructor and assignment operator are all privatized ... but don't seem to be able to.
Using a function pointer didn't work for me.
edit: using no macros as those are in general frowned upon as far as i know. / I know of the typedef, I was hoping for something simple relative like in other languages like
Singleton.method()
Also i've seen very few cases / answers on Stackoverflow that should good reasons to use a #define
This should be calling a library class from a main/usage perspective.
slightly relevant: How can I make an alias to a singleton function? but I don't need only a specific function.
idealized example:
defined library LIB.
user:
LIB::server_interface::get_instance()::do_something().
say said lib does automatic connection pooling / other operations. and you're interfacing extensively with some service, having to prepend the following extensively is a pain and does not make for pretty code. Furthermore as a user using the lib, you don't want to be putting namespace{
} in your code I would think.