but it doesn't work, the operator[] is defined for AccessClass
I searched the source as best I could and I found no place it's being used this way.
Instead I can do this:
It should work. core::map::operator[](const Key&) returns AccessClass which has a conversion operator to ValueType. Perhaps it would be good if you showed us an error message?
But, I have never really liked that way. Also, I think not drop()ing the result from tmap.find(core::stringc("Irrlicht")) would cause a memory leak, but I'm no expert on that.
(Oh, and I got errors doing it without the ->getValue and with the operator[] they had to do with type conversion if I remembered right, but I was using the same types!)
#include <irrlicht.h>
#include <stdio.h>
#pragma comment(lib, "irrlicht.lib");
using namespace irr;
int main ()
{
core::map<int, core::stringc> m;
m [1] = "the";
m [2] = "quick";
m [3] = "brown";
m [4] = "fox";
const core::stringc& s1 = m [1];
const core::stringc s2 = m [2];
core::stringc s3 = m [3];
printf ("1: %s\n2: %s\n3: %s\n",
s1.c_str(), s2.c_str(), s3.c_str());
return 0;
}
If you're having trouble, post a simple testcase and tell us what version of Irrlicht and your compiler you are using. That will help to figure out if it is a problem with your compiler, Irrlicht, or your code.
Hmm, oddly it works. I did a similar thing with stringc and char* indicies and it works. I'm not sure what I did before that failed but it is working now.
Well, I could go dig though my old backups and try to find a place where I was playing with them before, but it would take forever to find one. BUt it works now for unknown reasons, so thanks
Running MSVS 2008 Pro with Windows XP and Vanilla Irrlicht 1.5 I ran tests with my non-vinilla modified Irrlicht and it works too.
Well don't I feel foolish. The [] operator wouldn't work for me because I have a pointer to a map. It works beautifully once I dereference it first. Thank you all very much for the assistance.