www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - FixedString 2.0.0

reply Moth <su+dforum angel-island.zone> writes:
[Version 2.0.0 of 
FixedString](https://github.com/Moth-Tolias/fixedstring/releases/tag/v2.0.0),
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](https://github.com/Moth-Tolias/fixedstring)
[dub package](https://code.dlang.org/packages/fixedstring/2.0.0)
[documentation](https://fixedstring.dpldocs.info/v2.0.0/fixedstring.html)
[full 
changelog](https://github.com/Moth-Tolias/fixedstring/blob/main/CHANGELOG.md#200---2022-05-22)
May 22 2022
parent reply zoujiaqing <zoujiaqing gmail.com> writes:
On Sunday, 22 May 2022 at 15:16:59 UTC, Moth wrote:
 [Version 2.0.0 of 
 FixedString](https://github.com/Moth-Tolias/fixedstring/releases/tag/v2.0.0),
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](https://github.com/Moth-Tolias/fixedstring)
 [dub package](https://code.dlang.org/packages/fixedstring/2.0.0)
 [documentation](https://fixedstring.dpldocs.info/v2.0.0/fixedstring.html)
 [full 
 changelog](https://github.com/Moth-Tolias/fixedstring/blob/main/CHANGELOG.md#200---2022-05-22)
Thank you for work! What about his performance?
May 22 2022
parent Moth <su+dforum angel-island.zone> writes:
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.
May 22 2022