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 » The problem with 'Null'
Re: The problem with 'Null' [message #20449 is a reply to message #20446] Thu, 19 March 2009 08:42 Go to previous messageGo to previous message
gridem is currently offline  gridem
Messages: 45
Registered: August 2008
Member
I found a dirty trick:
template<typename T>
struct PickedVector : Vector<T>
{
	PickedVector()
	{
		Vector<T>() = *this;
	}
};

template<typename T>
const Vector<T>& VectorNull()
{
	return Single<PickedVector<T> >();
}

template<typename T>
bool IsNull(const Vector<T>& v)
{
	return v.IsPicked();
}

Cout() << "Is Null: " << IsNull(Vector<int>()) << EOL;
Cout() << "Is Null: " << IsNull(VectorNull<int>()) << EOL;

output:
Is Null: false
Is Null: true

and picked state may be treated as Null.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: In some cases CParser can be out of buffer
Next Topic: Possible bug/clarification only callback2 was changed for const Object*
Goto Forum:
  


Current Time: Thu Jun 13 03:25:10 CEST 2024

Total time taken to generate the page: 0.01464 seconds