std.mmfile + std.bitmanip.peek, void[] is not a forward range?

Ben Jones fake at fake.fake
Thu Nov 21 21:51:33 UTC 2024


I'm trying to read integers out of a mmap'd file using 
std.bitmanip.peek and it's failing because

`isForwardRange!(void[])` is false

That seems unexpected, am I missing something or is that a bug?

Am I doing something wrong here?

```
  scope mmFile = new MmFile(filename, MmFile.Mode.read, 0, null);

  void[] data = mmFile[]; //doesn't matter, same as slicing mmFile 
below
  int val = data[offset .. $].peek!int; //data[ offset .. offset + 
4] has same issue

```

Partial error:

```
Error: none of the overloads of template `std.bitmanip.peek` are 
callable using argument types `!(int)(void[])`
/opt/homebrew/Cellar/ldc/1.39.0_1/include/dlang/ldc/std/bitmanip.d(3416,3):        Candidates are: `peek(T, Endian endianness = Endian.bigEndian, R)(R range)`
   with `T = int,
        endianness = Endian.bigEndian,
        R = void[]`
   must satisfy the following constraint:
`       isForwardRange!R`
```


More information about the Digitalmars-d-learn mailing list