Re: Relocatable objects and internal pointers

2018-01-20 Thread timotheecour via Digitalmars-d-learn
On Saturday, 30 January 2016 at 03:13:59 UTC, Matt Elkins wrote: std.typecons.Unique seems to require heap allocation, which makes it a far cry from std::unique_ptr. isn't unique_ptr typically for heap allocation? eg: https://stackoverflow.com/questions/42910711/unique-ptr-heap-and-stack-allo

Re: Relocatable objects and internal pointers

2016-01-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/29/16 10:13 PM, Matt Elkins wrote: On Saturday, 30 January 2016 at 03:00:11 UTC, Steven Schveighoffer wrote: There are some really smart people who frequent these forums, if you post your actual use case, you may get an answer that you hadn't thought of. Yeah, I tried that first (on the g

Re: Relocatable objects and internal pointers

2016-01-29 Thread Matt Elkins via Digitalmars-d-learn
On Saturday, 30 January 2016 at 03:00:11 UTC, Steven Schveighoffer wrote: There are some really smart people who frequent these forums, if you post your actual use case, you may get an answer that you hadn't thought of. Yeah, I tried that first (on the general forum, since at the time I didn'

Re: Relocatable objects and internal pointers

2016-01-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/29/16 9:35 PM, Matt Elkins wrote: On Saturday, 30 January 2016 at 02:09:55 UTC, Steven Schveighoffer wrote: I figured out a way to have them. You just have to guarantee you don't copy the actual "pointer" out of the struct: https://forum.dlang.org/post/mk5k4l$s5r$1...@digitalmars.com Unf

Re: Relocatable objects and internal pointers

2016-01-29 Thread Matt Elkins via Digitalmars-d-learn
On Saturday, 30 January 2016 at 02:09:55 UTC, Steven Schveighoffer wrote: I figured out a way to have them. You just have to guarantee you don't copy the actual "pointer" out of the struct: https://forum.dlang.org/post/mk5k4l$s5r$1...@digitalmars.com Unfortunately, that won't work for what I

Re: Relocatable objects and internal pointers

2016-01-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/29/16 8:07 PM, Matt Elkins wrote: [snip] on D and came across a section in TDPL which said internal pointers are verboten because objects must be relocatable. Does this mean my example is invalid (e.g., the invariant will not hold in all circumstances)? If it is invalid, does that mean there

Re: Relocatable objects and internal pointers

2016-01-29 Thread Matt Elkins via Digitalmars-d-learn
On Saturday, 30 January 2016 at 01:28:54 UTC, H. S. Teoh wrote: On Sat, Jan 30, 2016 at 01:21:27AM +, Matt Elkins via Digitalmars-d-learn wrote: On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli wrote: >Definitely so. Rvalues are moved around all the time. The >following program has

Re: Relocatable objects and internal pointers

2016-01-29 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jan 30, 2016 at 01:21:27AM +, Matt Elkins via Digitalmars-d-learn wrote: > On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli wrote: > >Definitely so. Rvalues are moved around all the time. The following > >program has two rvalue moves without calling post-blits or > >destructor

Re: Relocatable objects and internal pointers

2016-01-29 Thread Matt Elkins via Digitalmars-d-learn
On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli wrote: Definitely so. Rvalues are moved around all the time. The following program has two rvalue moves without calling post-blits or destructors. Oi, that makes life tough. Ok, I'll figure something else out, then... Thanks for the

Re: Relocatable objects and internal pointers

2016-01-29 Thread Ali Çehreli via Digitalmars-d-learn
On 01/29/2016 05:07 PM, Matt Elkins wrote: > this(/* arguments to populate stuff */) > { > m_this = &this; > /* ... populate stuff ... */ > } > a section in TDPL which said internal pointers are > verboten because objects must be relocatable. Does this mean my ex

Relocatable objects and internal pointers

2016-01-29 Thread Matt Elkins via Digitalmars-d-learn
Hi all, I'm a C++ programmer trying to decide whether to switch my main focus to D, and so I'm working on a pet project using it. So far I really like some of the practical aspects of the language (built-in contracts are great, the metaprogramming is very accessible, and I can't enough of these