Using a struct as a wrapper for an extern(C) opaque type, no default constructor, what do?

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at
Wed Dec 16 20:55:51 PST 2015

On Thursday, 17 December 2015 at 04:05:30 UTC, Jeremy DeHaan 
> Thanks. I guess what bugs me is that I always try to hide the 
> fact that the API is a wrapper around C stuff, ie, I want to 
> make people feel as though they're using idiomatic D. Doing 
> something like this makes it feel like less idiomatic D and 
> more like a wrapper. I think I have a solution that I like in 
> my own case though. Right now I'm considering something like 
> this:

I completely understand your sentiment, but I don't see how 
default construction factors into it. D libraries that *aren't* 
wrappers around C libraries have the same restriction and have to 
make the same interface choices. Or did you mean something else?

Your code looks good, but make sure you either disable postblit 
or implement the postblit operator appropriately. The Rule of 
Three applies well to D.

More information about the Digitalmars-d-learn mailing list