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 » Newbie corner » stl question
Re: stl question [message #32797 is a reply to message #32796] Fri, 10 June 2011 07:55 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi GaroRobe,

You don't have to use new at all Wink Just creating a temporary object is fine, since std::vector will make a copy:
vector<Point2f> checkboardMesh;

for ( int i = 0; i < board_h; i++ )
		for ( int j = 0; j < board_w; j++ )
			checkboardMesh.push_back ( Point2f ( j, i ) );


Using U++ containers should be possible, but it would be an ugly hack Smile Something allong the lines of:
	using std::vector;
	using cv::Point2f;

	Vector<Point2f> v; //this requires to do NAMESPACE_UPP; NTL_MOVEABLE(cv::Point2f); END_UPP_NAMESPACE; in global scope

	vector<Point2f> checkboardMesh;

	for ( int i = 0; i < board_h; i++ )
		for ( int j = 0; j < board_w; j++ )
			v.Add( Point2f ( j, i ) );
	
	checkboardMesh.resize(v.GetCount());
	memmove(&checkboardMesh[0],v.Begin(),v.GetCount()*sizeof(Point2f));
In other words: not elegant and definitelly not recomended. Please never do something like that Wink

Honza
 
Read Message
Read Message
Read Message
Previous Topic: Restricting GridCtrl Selection to just One row
Next Topic: Please recommend a scripting language
Goto Forum:
  


Current Time: Tue Jul 08 06:30:47 CEST 2025

Total time taken to generate the page: 0.04335 seconds