On Saturday, 14 August 2021 at 20:50:47 UTC, Carl Sturtivant
wrote:
```
struct S {
int x = 1234;
}
void main() {
import std.stdio;
S s;
//construction of a using &(s.x)
auto a = Ref!(int)(&s.x);
writeln(a); //displays 1234
s.x += 1;
writeln(a); //displays 1235
a += 1;
On Monday, 16 August 2021 at 19:30:19 UTC, JG wrote:
On Sunday, 15 August 2021 at 21:53:14 UTC, Carl Sturtivant
wrote:
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote:
[...]
What you are asking for are reference variables. C++ has them:
the example here illustrates the behavior you want.
On Sunday, 15 August 2021 at 21:53:14 UTC, Carl Sturtivant wrote:
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote:
[...]
What you are asking for are reference variables. C++ has them:
the example here illustrates the behavior you want.
https://www.geeksforgeeks.org/references-in-c/
[...
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote:
Hi,
This is exactly the behaviour I was trying to obtain.
It however comes with a fair amount of overhead, as can be seen
in the following llvm ir:
[...]
What you are asking for are reference variables. C++ has them:
the example here il
On Sunday, 15 August 2021 at 16:49:22 UTC, Paul Backus wrote:
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote:
Hi,
This is exactly the behaviour I was trying to obtain.
It however comes with a fair amount of overhead, as can be
seen in the following llvm ir:
[...]
I'm not really fami
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote:
Hi,
This is exactly the behaviour I was trying to obtain.
It however comes with a fair amount of overhead, as can be seen
in the following llvm ir:
[...]
I'm not really familiar with llvm ir, but looking at it on
godbolt, it seems like
On Saturday, 14 August 2021 at 20:50:47 UTC, Carl Sturtivant
wrote:
```
struct S {
int x = 1234;
}
void main() {
import std.stdio;
S s;
//construction of a using &(s.x)
auto a = Ref!(int)(&s.x);
writeln(a); //displays 1234
s.x += 1;
writeln(a); //displays 1235
a += 1;
```
struct S {
int x = 1234;
}
void main() {
import std.stdio;
S s;
//construction of a using &(s.x)
auto a = Ref!(int)(&s.x);
writeln(a); //displays 1234
s.x += 1;
writeln(a); //displays 1235
a += 1;
writeln(s.x); //displays 1236
}
struct Ref(T) {
T* ptr;
this(T*
On Friday, 13 August 2021 at 19:06:17 UTC, JG wrote:
Anyway I hope it is clearer what I mean. Is it possible to do
this in d?
union S
{
int x;
int a;
}
void main()
{
S s= S(1234);
writeln(s.a); //displays 1234
s.x = s.x+1;
writeln(s.a); //displays 1235
s.a = s.a +1;
writ
On Friday, 13 August 2021 at 17:19:43 UTC, H. S. Teoh wrote:
On Fri, Aug 13, 2021 at 05:11:50PM +, Rekel via
Digitalmars-d-learn wrote: [...]
For anyone more experienced with C, I'm not well known with
references but are those semantically similar to the idea of
using a type at a predefined
On Fri, Aug 13, 2021 at 05:11:50PM +, Rekel via Digitalmars-d-learn wrote:
[...]
> For anyone more experienced with C, I'm not well known with references
> but are those semantically similar to the idea of using a type at a
> predefined location?
References are essentially pointers under the h
On Friday, 13 August 2021 at 09:10:18 UTC, Tejas wrote:
On Friday, 13 August 2021 at 08:25:33 UTC, JG wrote:
Suppose one has a pointer p of type T*.
Can on declare variable a of type T which is stored in the
location pointed to by p?
Umm is this what you want?
```d
import std.stdio;
struct S
On Friday, 13 August 2021 at 09:30:25 UTC, Ali Çehreli wrote:
(core.lifetime is not on dlang.org at the moment for me but it
is under /usr/include/dmd/druntime/import/core on my computer.)
It's also on dpldocs.info:
https://dpldocs.info/experimental-docs/core.lifetime.html
On 8/13/21 1:25 AM, JG wrote:
> Suppose one has a pointer p of type T*.
> Can on declare variable a of type T which is stored in the location
> pointed to by p?
You may be looking for core.lifetime.emplace. (core.lifetime is not on
dlang.org at the moment for me but it is under
/usr/include/dm
On Friday, 13 August 2021 at 08:25:33 UTC, JG wrote:
Suppose one has a pointer p of type T*.
Can on declare variable a of type T which is stored in the
location pointed to by p?
As an example if we have:
struct S
{
int x = 1234;
}
void main() {
S s;
//unkn
Suppose one has a pointer p of type T*.
Can on declare variable a of type T which is stored in the
location pointed to by p?
As an example if we have:
struct S
{
int x = 1234;
}
void main() {
S s;
//unknown construction of a using &(s.x)
writeln(a);
16 matches
Mail list logo