Casts and @trusted
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 13 21:02:13 PDT 2014
On 06/13/2014 06:56 PM, Anonymous wrote:
> @trusted void get_ref(TS strat=TS.cyclic)(size_t n, const(T*)[]
> refs) const nothrow
> {
[...]
> cast(T*) refs[i] = cast(T*) _buffer[read].ptr;
The left-hand side violates a promise: The function takes a slice where
the elemenst are const. So, the function says that it will not modify
the elements.
Also, _buffer[read] is an element, not a slice:
private T[cap] _buffer;
So, there is no .ptr property.
However, perhaps my test code fails to demonstrate your problem:
auto s = StaticRingBuffer!(int, 10)();
int i;
int*[] arr;
arr ~= &i;
s.get_ref(0, arr);
Please show us complete code. :)
Ali
More information about the Digitalmars-d-learn
mailing list