test case:
```
import std.uni : byGrapheme;
import std.range.primitives : walkLength;
enum a = "a".byGrapheme.walkLength;
void main(){}
```
std/uni.d(7631,16): Error: reinterpretation through overlapped field slen_ is not allowed in CTFE
Comment #1 by jack — 2018-01-08T15:20:57Z
Pretty sure there's a way to change a struct's layout if it's being used in compile time. All that needs to be done is just bring the fields out of the union when used in CTFE.
Comment #2 by jack — 2018-01-09T14:00:02Z
(In reply to Jack Stouffer from comment #1)
> Pretty sure there's a way to change a struct's layout if it's being used in
> compile time. All that needs to be done is just bring the fields out of the
> union when used in CTFE.
Apparently this isn't possible.
There are two ways of fixing this
1. remove the small string optimization from Grapheme
2. have byGrapheme return a specialized type of Grapheme that doesn't have SSO
Comment #3 by jack — 2018-01-09T14:01:45Z
(In reply to Jack Stouffer from comment #2)
> Apparently this isn't possible.
>
> There are two ways of fixing this
>
> 1. remove the small string optimization from Grapheme
> 2. have byGrapheme return a specialized type of Grapheme that doesn't have
> SSO
Or
3. Create a special function byGraphemeCTFE which is a range of CTFEGraphemes. That way there's no performance regression
Comment #4 by robert.schadek — 2024-12-01T16:31:52Z