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 » Value<int64> and Value<int> mess
Value<int64> and Value<int> mess [message #26719] Fri, 21 May 2010 10:36 Go to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

It looks like U++ int and int64 inside Value make mess.
In great number of cases, creating Value with int inside makes in Value<int64> instead. Which leads to assertion break while trying to process this Value. This is painfully and takes much time to debug.
I failed to find any conscious rules when int64 is generated instead of int. Take a look at this example:
int h = ValueTo<int>(StdConvertInt().Scan(ts.Left (delim)));
gives assertion error, because actually Value<int64> is generated.
Re: Value<int64> and Value<int> mess [message #26724 is a reply to message #26719] Fri, 21 May 2010 16:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Fri, 21 May 2010 04:36

It looks like U++ int and int64 inside Value make mess.
In great number of cases, creating Value with int inside makes in Value<int64> instead. Which leads to assertion break while trying to process this Value. This is painfully and takes much time to debug.
I failed to find any conscious rules when int64 is generated instead of int. Take a look at this example:
int h = ValueTo<int>(StdConvertInt().Scan(ts.Left (delim)));
gives assertion error, because actually Value<int64> is generated.


Before I start investigating, can you make my life easier and post what is in "delim" ?

(Other than that, all numeric Values - bool, int, int64, doubl - are interconvertible. So it should not really matter what is the source type).

Mirek
Re: Value<int64> and Value<int> mess [message #26726 is a reply to message #26724] Fri, 21 May 2010 18:22 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

I'm afraid these types are not interconvertible in my practice (ValueTo<> generates exception in many cases).
Here is simplified version of previous code:
CONSOLE_APP_MAIN
{
	String s = "11";
	int i = ValueTo<int>(StdConvertInt().Scan(s)); //generates exception
}


while this code works:
CONSOLE_APP_MAIN
{
	String s = "11";
	int i = ValueTo<int64>(StdConvertInt().Scan(s)); //OK!
}


It is just one of many cases (the absence of interconvertibility makes handling Ctrl::GetData() a headache too).

[Updated on: Fri, 21 May 2010 18:26]

Report message to a moderator

Re: Value<int64> and Value<int> mess [message #26760 is a reply to message #26726] Wed, 26 May 2010 13:41 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Fri, 21 May 2010 12:22

I'm afraid these types are not interconvertible in my practice (ValueTo<> generates exception in many cases).
Here is simplified version of previous code:
CONSOLE_APP_MAIN
{
	String s = "11";
	int i = ValueTo<int>(StdConvertInt().Scan(s)); //generates exception
}


while this code works:
CONSOLE_APP_MAIN
{
	String s = "11";
	int i = ValueTo<int64>(StdConvertInt().Scan(s)); //OK!
}


It is just one of many cases (the absence of interconvertibility makes handling Ctrl::GetData() a headache too).


It is because you are making your life hard using ValueTo Smile

Try this:

CONSOLE_APP_MAIN
{
	String s = "11";
	int i = StdConvertInt().Scan(s);
}


ValueTo is supposed to be used in two cases:

- as part of implementation of RichValue type (type with "full support" - hashcode, equality comparison, direct coversion)

- as a way to extract RawValue type (usually some of your type used to implement something, when you do not bother about RichValue traits, just simply need to pass such type as Value through).

Sorry for incomplete docs. In fact, Value is one of last places without proper documentation - unfortunately it is also one that quite hard to document....
Previous Topic: Date is broken for years below one.
Next Topic: CHARSET: EE8ISO8859P2 is in u++?
Goto Forum:
  


Current Time: Wed Apr 24 02:36:40 CEST 2024

Total time taken to generate the page: 0.03890 seconds