X
Xavier Decoret
Let's say I want assign a unique int id to a set of string. The
following code is pretty compact and handy:
deque<string> names; // I know there are unique
map<string,int> idMap;
for (deque<string>::const_iterator iter = names.begin();
iter != names.end();++iter)
{
idMap[*iter] = idMap.size();
}
After that I can use the idMap to retrieve the unique id of a string.
QUESTION:
---------
On my implementation, the first string has id 1. I understand that
idMap[*iter] is evaluated first so when the right hand term is
evaluated, idMap do have a size() of 1.
Can I trust this to be the case on any implementation or the order of
evalutation for an assignement is not specified?
--
+-------------------------------------------------+
| Xavier Décoret - Post Doct |
| Graphics Lab (LCS) - MIT |
| mailto: (e-mail address removed) |
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+
following code is pretty compact and handy:
deque<string> names; // I know there are unique
map<string,int> idMap;
for (deque<string>::const_iterator iter = names.begin();
iter != names.end();++iter)
{
idMap[*iter] = idMap.size();
}
After that I can use the idMap to retrieve the unique id of a string.
QUESTION:
---------
On my implementation, the first string has id 1. I understand that
idMap[*iter] is evaluated first so when the right hand term is
evaluated, idMap do have a size() of 1.
Can I trust this to be the case on any implementation or the order of
evalutation for an assignement is not specified?
--
+-------------------------------------------------+
| Xavier Décoret - Post Doct |
| Graphics Lab (LCS) - MIT |
| mailto: (e-mail address removed) |
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+