mortoray/quantlib — comment on commit dbf6b23429b21cccb0982d6f3e5c13f5860842e1
File: ql/patterns/singleton.hpp line 95
By mortoray:

The purpose behind the setup (including "create" and void*) was not to
be flexible, but rather to be able to put the thread dependent code in a
CPP file. If we use the direct type, then all of the code has to be in
the header file, which means any user of this file also has to include
the entire set of boost threading headers (and would have to link
directly to those libraries). That is what I am avoiding by doing this
-- users of QuantLib can be oblivious to the locking used.

So, no, "create" will always use "new". It's just a way to abstract that
type-dependent bit for the CPP file.

On 02/12/2012 03:17 PM, Luigi Ballabio wrote:
> Do you have any use case in mind in which `create()` should not use `new`?
> Also, right now there's no way to pass another function to `SingletonInstanceLoader` (since it can't be passed to the `instance()` method which calls it) and `create()` is not virtual, so it can't be overridden. So we end up always using `new` anyway.
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/mortoray/quantlib/commit/dbf6b23429b21cccb0982d6f3e5c13f5860842e1#commitcomment-957739
>
>

--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.