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 » ConvertInt > templatable Convert<T>
Re: this one worked for me [message #22828 is a reply to message #22826] Thu, 20 August 2009 16:26 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Well, the problem is that you are trying to use types that cannot have a Null defined for them (this is usually the case for smaller variants of a type, float and short for instance). These cannot be directly converted to and from Values.

I actually should have removed all of these types from my version as it won't work compile (as you discovered). Hacking in arbitrary Null values isn't a very good solution IMO.

What I hadn't thought of before was that the task would be much more easily accomplished with something like:
struct ConvertUnsignedChar : public ConvertInt
{
	ConvertUnsignedChar() {	MinMax(0, 255); }	
};

template <class CONVERT, const int CHARS>
struct EditCustom : public EditMinMax<int, CONVERT >
{
	EditCustom() { MaxChars(CHARS); }
};

typedef EditCustom<ConvertUnsignedChar, 3> EditUnsignedChar;
(This would be even simpler if you didn't need the max chars)

Since you're doing all the RTTI typeid stuff internally anyway, why not just do it in a function somewhere to create the correct type of EditField/Convert and avoid all the horrific bodging?
 
Read Message
Read Message
Read Message
Read Message icon14.gif
Read Message
Previous Topic: GZDecompress bug
Next Topic: compressed serialization
Goto Forum:
  


Current Time: Tue May 14 18:37:58 CEST 2024

Total time taken to generate the page: 0.02677 seconds