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 » Community » Newbie corner » Value strange behaviour result in ValueTypeError
Re: Value strange behaviour result in ValueTypeError [message #51797 is a reply to message #51791] Sat, 01 June 2019 11:32 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello Xemuth,

Novo is right.

You are implicitly trying to convert a string "Value" to bool, which is not possible that way.

VectorMap<String, String> ConfigurationType;

template <class T>
bool testAddVector(String keyname, const T& t)
{
	ConfigurationType.Add(keyname, t); // You have implicitly tried to convert a string "Value" into a bool "Value" (hence the "Value" error)
	return true;
}

ValueMap vmap;

void TestValueMap(Value key, Value val) // Just change the key's signature to String if you want to limit the key type...
{
	vmap.Add(key, val);
}

CONSOLE_APP_MAIN
{
		StdLogSetup(LOG_COUT|LOG_FILE);
		
		String s = "world";
		testAddVector("Hello", s);
		DUMP(ConfigurationType.ToString());
		
		// If possible, I suggest using a ValueMap.
		
		TestValueMap("Hello", "World");
		TestValueMap(1, "This is a test");
		TestValueMap("This is a test too!", 2);
		
		DUMP(vmap);
}



Best regards,
Oblivion


[Updated on: Sat, 01 June 2019 11:36]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Memory leaks ?
Next Topic: Tricky template non-typeParameter
Goto Forum:
  


Current Time: Tue May 07 05:17:54 CEST 2024

Total time taken to generate the page: 0.02715 seconds