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

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 14 14:26:05 PST 2013


On Thu, 14 Feb 2013 15:33:19 -0500, Ivan Kazmenko <gassa at mail.ru> wrote:

> ... I get only exactly 3 * LIMIT postblit constructor calls, which is  
> 300,000 instead of 11,389,556.  While I still want to find where the  
> excess 200,000 calls originate from, this is definitely asymptotically  
> better than before

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


More information about the Digitalmars-d-learn mailing list