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 » A probably simple question about pick semantics
A probably simple question about pick semantics [message #34794] Mon, 12 December 2011 16:58 Go to previous message
peek is currently offline  peek
Messages: 13
Registered: March 2010
Promising Member
I wanted to pass a Vector by reference to a template function, but the Vector is lost Sad :

.cpp file

Vector<double> v;
v << 1;

Test(v);


.h file

template <class T>
void Test(T v)
{
	// Nothing done
}


After calling to Test(), Vector v contents disappear.

When debugging you can see than before jumping to Test(), the compiler call to Vector pick constructor:

Vector(pick_ Vector& v)          { Pick(v); }


and before leaving Test(), the compiler calls Vector destructor:

~Vector()  { ....


However if Test is called with a pointer to Vector, v contents remains.

Test(&v)


What could we do to call the templated function without loosing Vector contents?

Thank you Smile
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: gdk_pixbuf-2.0 linker error
Next Topic: Small fix for Find in Algo.h
Goto Forum:
  


Current Time: Sun May 12 22:13:45 CEST 2024

Total time taken to generate the page: 0.02344 seconds