Boost logo

Boost Users :

Subject: Re: [Boost-users] [Singleton] When CRTP won't work
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-16 12:58:43


AMDG

Alexander wrote:
> The current version of Boost candidate Signelton as well as other
> implementation is CRTP base.
> However, one may want to use it as local class
>
> my_class& get_something(std::string const& param)
> {
> struct local : singleton<local>
> {
> ...
> };
> return local::instance->some_method(param);
> }
>

The problem is not CRTP, per se, but templates.
It is not legal to pass a local class as a template
parameter. I don't see how you can implement a
singleton generically without using templates.
Sorry, but I think the only solution is to move
the local class to namespace scope.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net