https://issues.dlang.org/show_bug.cgi?id=23164

--- Comment #4 from Mathias LANG <[email protected]> ---
> Remember that D does not allow internal pointers to members.

If memory serves me well, Andrei mentioned a few years ago that this position
is no longer tenable. Not supporting internal pointers means users cannot
interface with `std::string`, which is a huge blow too C++ interop. And
internal pointers are one of the reasons we got the copy constructors, aren't
they ?

> I find the `auto ref` parameter suspicious. What are you expecting to happen 
> there? Do you expect it to be passed by ref or by value? 

I expect a single constructor call for a value constructed in the caller.
In other word, I expect:
```
    tmp = std_string(42);
```
and:
```
    auto someLValue = std_string(42);
    tmp = someLValue;
```

to only call `std_string` constructor once.
If I don't use `auto ref` (pass by value), the code will compile for both
snippets above but in the case of `someLValue`, it will call the constructor
one more time.
If I use plain `ref`, the code will not compile for the first snipped (passing
a rvalue).

Note that the original test case was using `in`, which is just `ref` accepting
rvalue, so I doubt `auto ref` is at fault here (especially considering LDC and
GDC don't have the bug, only DMD does).

--

Reply via email to