July 15, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | Yes yes, I will use the ref... is more safer!
I will try to re-create my logic...
btw, how is the best way to "reinterpret" this ??:
map<string, Address> syms;
and:
vector<pair<DWORD, Address>> values;
vector<pair<DWORD, shared_ptr<DWORD>>> addrs;
On Tuesday, 15 July 2014 at 14:55:36 UTC, bearophile wrote:
> Alexandre:
>
>> as rc is better for managing scarce resources like file handles.
>
> File instances are ref counted in D. Is this useful for you?
>
> Bye,
> bearophile
|
July 15, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexandre | Alexandre: > map<string, Address> syms; If you don't need the key ordering then use a built-in associative array: Address[string] syms; Otherwise use a RedBlackTree from std.container. > vector<pair<DWORD, Address>> values; > vector<pair<DWORD, shared_ptr<DWORD>>> addrs; Tuple!(DWORD, Address)[] values; Tuple!(DWORD, DWORD*)[] addrs; Tuple and tuple are in std.typecons. Bye, bearophile |
July 15, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexandre | On 07/15/2014 07:40 AM, Alexandre wrote: > I have this struct: I think many short discussion threads are more efficient than a single long thread. Many different C++ and D concepts are making this thread difficult to follow for me. :) Ali |
July 17, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 15 July 2014 at 16:04:26 UTC, bearophile wrote:
> Alexandre:
>
>> map<string, Address> syms;
>
> If you don't need the key ordering then use a built-in associative array:
>
> Address[string] syms;
>
> Otherwise use a RedBlackTree from std.container.
>
>
>> vector<pair<DWORD, Address>> values;
>> vector<pair<DWORD, shared_ptr<DWORD>>> addrs;
>
> Tuple!(DWORD, Address)[] values;
> Tuple!(DWORD, DWORD*)[] addrs;
>
> Tuple and tuple are in std.typecons.
>
> Bye,
> bearophile
For `Tuple!(DWORD, DWORD*)[] addrs;`, DWORD* is not same as shared_ptr<DWORD>. It's important to keep that in mind.
|
July 17, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | Meta:
> For `Tuple!(DWORD, DWORD*)[] addrs;`, DWORD* is not same as shared_ptr<DWORD>. It's important to keep that in mind.
OK. How do you suggest to translate it in D?
Bye,
bearophile
|
July 17, 2014 Re: SImple C++ code to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Thursday, 17 July 2014 at 13:40:20 UTC, bearophile wrote:
> Meta:
>
>> For `Tuple!(DWORD, DWORD*)[] addrs;`, DWORD* is not same as shared_ptr<DWORD>. It's important to keep that in mind.
>
> OK. How do you suggest to translate it in D?
>
> Bye,
> bearophile
I don't know. I just wanted to make sure OP knew that raw pointers in D are not analogous to C++ shared_ptr.
|
Copyright © 1999-2021 by the D Language Foundation