Windows bindings

Elronnd elronnd at elronnd.net
Tue Feb 16 21:35:32 UTC 2021


On Saturday, 13 February 2021 at 00:32:30 UTC, Rumbu wrote:
> 4) On RAIFree attribute
>
> Most of the specific handles are decorated with this attribute 
> stating the function meant to free the handle. Example:
>
> [RAIIFree(CloseDC)]
> struct HDC ...

struct RaiiFreer(T, alias f) {
	T x;
	alias x this;
	~this() {
		f(x);
	}
}
struct realHDC { original contents... }
alias HDC = RaiiFreer!(realHDC, CloseDC);

And make the win32 functions take a realHDC, but users declare 
HDC to get raii semantics.


More information about the Digitalmars-d mailing list