Defining a custom *constructor* (not initializer!)

Jacob Carlborg doob at me.com
Mon May 7 12:57:59 PDT 2012


On 2012-05-07 11:18, David Nadlinger wrote:
> On Monday, 7 May 2012 at 07:28:18 UTC, Mehrdad wrote:
>> Is this something that actually modifies the 'new' operator, or is it
>> just a separate factory function that my code would need to switch to
>> using?
>
> Doing it without a separate factory function (and maybe disabling new
> along with it by protecting the constructor) is not possible in D.
> However, I don't quite see what it would gain you in the first place –
> besides potentially screwing up the semantics users expect from new…
>
> David

http://pastebin.com/UV5R82dg

A bit of a hack. An other option would to use a separate public method 
that acts as a constructor.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list