std.container.RedBlackTree versus C++ std::set

Namespace rswhite4 at googlemail.com
Thu Feb 14 14:44:05 PST 2013


> As I said elsewhere, the issue is D not having a good solution 
> for accepting both rvalues and lvalues by ref.  Jonathan 
> mentioned auto ref, but it's not exactly implemented correctly.
>
> In C++, it just takes all parameters as const T&, and that 
> works for both lvalues and rvalues.
>
> The extra 200k copies are from the implementation taking all 
> parameters by value.  If we didn't do that, sans a working auto 
> ref, things like tree.insert(element(5)) would fail to compile 
> (cannot pass an rvalue by reference)
>
> -Steve

And Jonathan said also that 'auto ref' is not the solution for 
non-template functions.
Probably 'auto ref' will never work for non-template functions. 
So a general solution must be found first.


More information about the Digitalmars-d-learn mailing list