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 » user 'Value' [FEATURE REQUEST]
Re: user 'Value' [FEATURE REQUEST] [message #3455 is a reply to message #3437] Thu, 25 May 2006 21:26 Go to previous messageGo to previous message
mr_ped is currently offline  mr_ped
Messages: 826
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
I think the solution with inheritance is the most easy and usefull one.

template <class T>
class ArrayWithVal : public Array<T>, Moveable< ArrayWithVal<T> > {
public:
	Value		userValue;
};


(Maybe "MoveableAndDeepCopyOption< ... >" can be used, but Value is just "Moveable", and so I'm not sure if the DeepCopy would be still possible)

I don't think such short piece of code is worth of addition to UPP core. Actually this is the most simple example of what is OOP capable of, and why it has advantages over procedural programming for certain tasks (like this one).

Anyway, I think the "Value" is a good choice in UPP as long as you don't care about it's size in memory (i.e. you will not produce hundrets instances of that class together).

Other common solution is to use void *, or DWORD type.
Both of them allow you to store 32bit ints into user value. The void * is also more understandable if you put there pointer pointing to your custom structure holding more values.
Buth those two are usual for plain C code, and as I said, Value is very good choice in UPP, unless you are memory consumption concerned.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: short-hand
Next Topic: container.At(not_existed_item_index)
Goto Forum:
  


Current Time: Thu Aug 07 11:17:40 CEST 2025

Total time taken to generate the page: 0.04072 seconds