Stack allocated arrays

bearophile bearophileHUGS at lycos.com
Sat Nov 17 18:27:51 PST 2012


Namespace:

> Code: http://dpaste.dzfl.pl/6ae9f91a

I think you can't use alloca() lie this, buf vanishes when the
constructor ends:

	this(const size_t len)(ref T[len] arr) {
		this._buf = cast(T*) alloca(len * T.sizeof);
		
		for (size_t i = 0; i < len; ++i) {
			this._buf[i] = arr[i];
		}
		
		this._length = len;
	}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list