Using non-copyable types

Yuxuan Shui yshuiv7 at gmail.com
Thu May 23 18:33:04 UTC 2019


On Thursday, 23 May 2019 at 18:18:02 UTC, H. S. Teoh wrote:
> On Thu, May 23, 2019 at 06:05:41PM +0000, Yuxuan Shui via 
> Digitalmars-d wrote:
>> [...]
>
> Wrap them in a reference. I.e., instead of passing the range 
> itself, pass a pointer to the range. Or use a suitable wrapper 
> struct with reference semantics.  Thanks to D unifying member 
> invocation via object and via pointer to object, this should be 
> mostly transparent to Phobos algorithms. This gets around the 
> complications with postblits / copy ctors and Phobos 
> assumptions about copyability.
>
> 	NonCopyableRange r = ...;
> 	auto rp = &r;
> 	result = rp.map!(...).filter!(...).joiner; // etc.
>
>
> T

What about Tuple?

These are probably not the best examples, I just sense there is a 
general lack of consideration of non-copyable types in phobos.



More information about the Digitalmars-d mailing list