Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » C++11
Re: C++11 [message #38171 is a reply to message #38150] Mon, 03 December 2012 11:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Lance wrote on Sun, 02 December 2012 15:00


A class not written with pick_ in mind will(or may?) not work correctly with Upp::Vector<>, even if it meets all the interface requirements superficially.



Actually, that is not true. pick_ is in no way related with generic requirement of Vector elements (only 2-3 methods require it).

Please note that pick semantics and Moveable are two very different things.

pick indeed is a variant of rvalue and it might have sense to replace it with r-value. Unfortunately, rvalue lacks composition rules, which means that it has to be reimplemented for any composite type, while pick generates compiler generated composite pick operations without problems. How much more code it would mean in practice is something that I plan to test is some branch in future. But e.g. for something like RichTxt::Para, it will be nasty.

Anyway, pick is not used for performance reasons in Vector. Moveable is. And that is still a bit ahead than pick/&&.

Pick is rather interface issue, allows you to pass objects from place to place without copying them (which do not even has to be available).

Mirek
Re: C++11 [message #38172 is a reply to message #38147] Mon, 03 December 2012 11:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Lance wrote on Sun, 02 December 2012 13:30

If U++ will adopt rvalue references, will it create the possibility of getting rid of Vector and many other containers/algorithms?


Note: You can use most STL algorithms with U++ containers now, as long as elements satisfy STL requirements, and vice versa.

However, sometimes U++ algorithms are better suited for U++ concrete types (and, again, vice versa). For example, U++ Sort is fater than than std::sort for Vector<String>, but slower for std::vector<std::string> (~30%), as there are subtle choices in algorithm that can favor one or another set of types.

Mirek
Re: C++11 [message #38182 is a reply to message #38172] Tue, 04 December 2012 00:55 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Thanks Mirek. I got it.

So U++'s Vector would still outperform std::vector significantly for classes have move constructor and move assignment defined?
Re: C++11 [message #38183 is a reply to message #38182] Tue, 04 December 2012 08:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Lance wrote on Mon, 03 December 2012 18:55

Thanks Mirek. I got it.

So U++'s Vector would still outperform std::vector significantly for classes have move constructor and move assignment defined?


Well, it depends on many factors, but generally yes.

The difference is that when expanding std::vector, the code still has to iterate through all elements and move them (albeit using &&). Vector simply performs memcpy on raw data.

Now it is possible that the std::vector iteration could in the end be optimized by compiler to something like memcpy, as long as compiler sees the inlined move contructor, in that case the performace should be similar. But in the end, Vector always does memcpy Smile

Mirek
Re: C++11 [message #39472 is a reply to message #38183] Tue, 19 March 2013 03:24 Go to previous message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel

http://cpprocks.com/c11-compiler-support-shootout-visual-stu dio-gcc-clang-intel/
Previous Topic: live session Prague 8.3.2013
Next Topic: Have Visual Studio? Looking for prebuilt SDL 2.0
Goto Forum:
  


Current Time: Fri Mar 29 00:24:21 CET 2024

Total time taken to generate the page: 0.01494 seconds