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 |
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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 01 June 2019 11:36] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue May 07 05:17:54 CEST 2024
Total time taken to generate the page: 0.02715 seconds
|