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 » U++ Library support » U++ Core » Fixes to Array::Create & Vector::Create
Re: Fixes to Array::Create & Vector::Create [message #49077 is a reply to message #49076] Fri, 15 December 2017 09:10 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Novo wrote on Fri, 15 December 2017 03:46
Hi Mirek,

Could you please change methods Array::Create & Vector::Create to make them look like below?
	template<class TT, class... Args>
	TT& Create(Args&&... args)          { TT *q = new TT(pick(args)...); Add(q); return *q; }

	template <class... Args>
	T&       Create(Args&&... args)    { if(items >= alloc) GrowF(); return *(::new(Rdd()) T(pick(args)...)); }

This shouldn't break anything, and as a bonus this should allow to pass arguments by reference in case they do not have a copy constructor, what is quite common with Upp.

Regards,


Just changing them to r-value would potentially break a lot. However, I am trying to add them as overload.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Performance problem with XmlParser::Next()
Next Topic: how to use xmlparser to parse this document?
Goto Forum:
  


Current Time: Mon Aug 25 13:03:08 CEST 2025

Total time taken to generate the page: 0.05851 seconds