Home » U++ Library support » U++ Core » VectorMap<String,String> = Seg Fault
( ) 1 Vote
VectorMap<String,String> = Seg Fault [message #28108] |
Tue, 17 August 2010 07:32  |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I have the following program which I believe should work:
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
VectorMap<String,String> map;
map.Put("A", "B");
map.Put("C", "D");
map.Put("E", "F");
Vector<String> keys = map.GetKeys();
for (int i = 0; i < keys.GetCount(); i++)
Cout() << map.Get(keys[i]) << "\n";
}
however, it fails with the exception:
Assertion failed in /home/jeremy/upp/svn/uppsrc/Core/Vcont.h, line 33
i >= 0 && i < items
Segmentation fault
Any thoughts?
Jeremy
|
|
|
|
|
Re: VectorMap<String,String> = Seg Fault [message #28122 is a reply to message #28108] |
Tue, 17 August 2010 17:58   |
|
This particular case with GetKeys() (and GetValue() too) is quite tricky for new users... I was fighting with it quite often myself. Even when I became aware of the pick behaviour and I was watching my steps carefully, this one always escaped my attention. I guess it is because it seems to human brain that you are getting some newly created Vector of keys, but internally it really works with the actual keys.
Maybe we should mention this in U++ traps and pitfalls...
Honza
[Updated on: Tue, 17 August 2010 17:59] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:28:34 CEST 2025
Total time taken to generate the page: 0.01219 seconds
|