Moth-Tolias / fixedstring

a safe, nogc-compatible templated array type, originally for strings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fixedstring

a templated fixed-length array of chars, compatible with @safe, @nogc, and nothrow code.

example

void main() @safe @nogc nothrow
{
	FixedString!14 foo = "clang";
	foo[0] = 'd';
	foo ~= " is cool";
	assert(foo == "dlang is cool");

	foo.length = 9;

	immutable bar = fixedString!"neat";
	assert(foo ~ bar == "dlang is neat");

	// wchars and dchars are also supported
	assert(FixedString!(5, wchar)("áéíóú") == "áéíóú");

	// in fact, any type is:
	immutable int[4] intArray = [1, 2, 3, 4];
	assert(FixedString!(5, int)(intArray) == intArray);
}

read the documentation for more info!

licence

AGPL-3.0 or later

About

a safe, nogc-compatible templated array type, originally for strings.

License:GNU Affero General Public License v3.0


Languages

Language:D 100.0%