pImpl in D
Dejan Lekic via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 4 05:12:22 PDT 2017
On Tuesday, 4 April 2017 at 12:05:15 UTC, Satoshi wrote:
> Hi,
> do someone have any experience with pImpl and inheritance in D?
Some parts of Phobos use it. Example:
https://github.com/dlang/phobos/blob/master/std/stdio.d
Have a look at the struct ByLine
It has something like:
struct ByLine(Char, Terminator)
{
private:
import std.typecons : RefCounted,
RefCountedAutoInitialize;
/* Ref-counting stops the source range's Impl
* from getting out of sync after the range is copied,
e.g.
* when accessing range.front, then using std.range.take,
* then accessing range.front again. */
alias PImpl = RefCounted!(Impl,
RefCountedAutoInitialize.no);
PImpl impl;
More information about the Digitalmars-d
mailing list