On 1/2/23 15:14, Paul Backus via Digitalmars-d-learn wrote:
On Monday, 2 January 2023 at 22:53:13 UTC, Charles Hixson wrote:
I want to return values of the template parameter type, so there doesn't seem to be any way to dup or idup them.

It's hard to say where exactly you're going wrong if you only post the error message, without the code that produced it. If you post your code (or a simplified version with the same problem), I'm sure someone will be able to help you.

I don't really know where to start.  dup doesn't reliably work on template parameters.  Assignment returns things that may have internal pointers.  The code is 5-6 lines of testing this approach or that, and every single one of them has failed.  Some approaches will work with strings, but not with ints, some with ints but not with strings, some may return pointers to internal data.  What I'm trying to do is return data that will be const or immutable from a function.  They syntax I wanted was something like:

bool func (const out Key k, const out Val v) { k = this.key.dup; v = this.val.dup; return true;    }

but that fails six or seven different ways.

--
Javascript is what you use to allow third part programs you don't know anything 
about and doing you know not what to run on your computer.

Reply via email to