I'm working on a C++ project where a small language is implemented. In fact, the main consists on a kind of "pseudo-instructions" where I use the preprocessor to translate them into valid C++ code.
This is part of the line in the main.cpp:
REGEX(name) ...(currStr defined here)... END
and on the .h file I have:
std::map<std::string, std::regex> regex_map;
std::string regex_name;
#define REGEX(name) \
std::regex name; \
regex_map[#name] = name; \ //exception here
... \
#define END \
regex_map.find(regex_name)->second.assign(currStr,std::regex::ECMAScript); \
I want to create a map containing the regex and the string representing the regex's name but the string that would be the value of the regex isn't known until we reach END. So I want to insert a pair in the map with an empty regex on the REGEX(name) macro and then on the END macro, by using the regex's name to find the pair on the map, I want to assign the string to the regex.
But even though the project is built just fine, on the line I show above I get an exception:
Unhandled exception at 0x0097171F in (project name).exe: 0xC0000005: Access violation reading location 0x00000000.
Any idea why this happens and how I can achieve what I want to do?
Aucun commentaire:
Enregistrer un commentaire