Thank you all for your responses. I understand that the compiler
can't ensure @safe and @trusted is needed.. I'm not familiar
though with all aspects of D and thought I might have missed
something.
On Friday, 12 July 2019 at 01:24:06 UTC, Jonathan M Davis wrote:
BTW, if you're implementing mem
On Thursday, 11 July 2019 at 19:35:50 UTC, Stefanos Baziotis
wrote:
On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote:
Casting from one type of pointer to another and slicing a
pointer are both @system, by design.
Yes, I'm aware, there are no pointers in the code. The pointer
was
On Thursday, July 11, 2019 1:44:51 PM MDT Stefanos Baziotis via Digitalmars-
d-learn wrote:
> On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote:
> > If you know that what you're doing cannot result in memory
> > corruption but the compiler cannot automatically infer @safe,
> > it is approp
On Thursday, 11 July 2019 at 19:44:51 UTC, Stefanos Baziotis
wrote:
On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote:
If you know that what you're doing cannot result in memory
corruption but the compiler cannot automatically infer @safe,
it is appropriate to use @trusted. (For this
On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote:
If you know that what you're doing cannot result in memory
corruption but the compiler cannot automatically infer @safe,
it is appropriate to use @trusted. (For this case make sure
you're not returning the byte slices, since if the a
On Thursday, 11 July 2019 at 16:31:58 UTC, Stefanos Baziotis
wrote:
I searched the forum but did not find something.
I want to do this:
int foo(T)(ref T s1, ref T s2)
{
const byte[] s1b = (cast(const(byte)*)&s1)[0 .. T.sizeof];
const byte[] s2b = (cast(const(byte)*)&s2)[0 .. T.sizeof];
On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote:
What's the actual problem you're trying to solve? There may be
a different way to do it that's @safe.
I hope I answered the "what". In case the "why" helps too, it is
because
I'm implementing memcmp().
On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote:
Casting from one type of pointer to another and slicing a
pointer are both @system, by design.
Yes, I'm aware, there are no pointers in the code. The pointer
was used
here because it was the only way to solve the problem (but not
On Thursday, 11 July 2019 at 16:31:58 UTC, Stefanos Baziotis
wrote:
I searched the forum but did not find something.
I want to do this:
int foo(T)(ref T s1, ref T s2)
{
const byte[] s1b = (cast(const(byte)*)&s1)[0 .. T.sizeof];
const byte[] s2b = (cast(const(byte)*)&s2)[0 .. T.sizeof];
I searched the forum but did not find something.
I want to do this:
int foo(T)(ref T s1, ref T s2)
{
const byte[] s1b = (cast(const(byte)*)&s1)[0 .. T.sizeof];
const byte[] s2b = (cast(const(byte)*)&s2)[0 .. T.sizeof];
}
Which is to create a byte array from the bytes of the value
given
10 matches
Mail list logo