Re: Casts and @trusted

2014-06-14 Thread Anonymous via Digitalmars-d-learn
That really is it. The other methods are just other gets to the buffer, like this: T[] get_dup(TS strat=TS.cyclic)(size_t n) const { static if (strat==TS.once) size_t numreads = fixNToFill(n); else size_t numreads = n; auto ret = new T[](numreads); size_t

Re: Casts and @trusted

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
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

Casts and @trusted

2014-06-13 Thread Anonymous via Digitalmars-d-learn
This seems to work from quick testing, but it has casts in get_ref that I want to avoid. cast(T*) refs[i] is obviously not @safe. cast(T*) _buffer[read].ptr doesn't seem necessary, since _buffer[read] is conceivably a T so _buffer[read].ptr should be a T*. But without it I get "Error: cannot im