Thread overview
FixedString 2.0.0
May 22, 2022
Moth
May 22, 2022
zoujiaqing
May 22, 2022
Moth
May 22, 2022

Version 2.0.0 of FixedString, my @safe @nogc nothrow array type, has been released.

This version is mostly compatible with 1.2.0, but the helper template FixedString!"foo" has been changed to fixedString!"foo" to comply with the standard D style convention. Furthermore, the range api has been totally overhauled; in particular, opIndex() now returns a range (random access, with slicing) rather than a raw slice, and the functions empty(), front(), and popFront() have thus been removed from the container.

Previously, it was possible to modify out-of-bounds elements with opIndex if the maximum size of the FixedString would allow it. This behaviour does not align with that of native dynamic arrays, however, so it has been removed. The correct way to perform this action is to either use the ~= operator, or alternatively set the length to an appropriate value beforehand.

It is now possible to use FixedString with types that use the garbage collector, throw, or have otherwise unsafe behaviour, as the element type. This was impossible in 1.x.x as almost every function had the @nogc nothrow pure @safe attributes applied. However, templates in D automatically infer their attributes - meaning this restriction was unnecessary. As such, it has been lifted.

There have also been a number of fixes.

  • opAssign, opOpAssign, opEquals, concat and opBinary all assumed they would only ever be used with the char element type. This oversight has been fixed.
  • opSlice is now bounds checked.

And finally, FixedString is now compatible with dip1000.

repository
dub package
documentation
full changelog

May 22, 2022

On Sunday, 22 May 2022 at 15:16:59 UTC, Moth wrote:

>

Version 2.0.0 of FixedString, my @safe @nogc nothrow array type, has been released.

This version is mostly compatible with 1.2.0, but the helper template FixedString!"foo" has been changed to fixedString!"foo" to comply with the standard D style convention. Furthermore, the range api has been totally overhauled; in particular, opIndex() now returns a range (random access, with slicing) rather than a raw slice, and the functions empty(), front(), and popFront() have thus been removed from the container.

Previously, it was possible to modify out-of-bounds elements with opIndex if the maximum size of the FixedString would allow it. This behaviour does not align with that of native dynamic arrays, however, so it has been removed. The correct way to perform this action is to either use the ~= operator, or alternatively set the length to an appropriate value beforehand.

It is now possible to use FixedString with types that use the garbage collector, throw, or have otherwise unsafe behaviour, as the element type. This was impossible in 1.x.x as almost every function had the @nogc nothrow pure @safe attributes applied. However, templates in D automatically infer their attributes - meaning this restriction was unnecessary. As such, it has been lifted.

There have also been a number of fixes.

  • opAssign, opOpAssign, opEquals, concat and opBinary all assumed they would only ever be used with the char element type. This oversight has been fixed.
  • opSlice is now bounds checked.

And finally, FixedString is now compatible with dip1000.

repository
dub package
documentation
full changelog

Thank you for work!
What about his performance?

May 22, 2022

On Sunday, 22 May 2022 at 15:37:24 UTC, zoujiaqing wrote:

>

Thank you for work!
What about his performance?

thank you for your interest!
as far as i know it's as fast as can be - it's just a struct wrapping an array.