In C++11 is there any defined behaviour regarding the following? (i.e. does a = 1, 2 or is undefined)
void somefunc(int a, int b) {
std::cout << a << b << std::endl;
}
int i = 0;
somefunc(++i, ++i)
Or should I write:
int i = 0;
int a = ++i;
int b = ++i;
somefunc(a, b);
The reason I ask, is I'm parsing a file for options and in one circumstance I'd like to create a keyvalue pair. And have functions similar to the following:
std::string create_key(std::string &source, size_t &size, int &index) {
std:: string key = "";
while(index < size) {
// parse the string to create the key
++index
}
return key;
}
// Value is an base class for a template class. Allowing me to store values
// of different data types inside a container.
Value* create_value(std::string &source, size_t &size, int &index) {
Value* value = nullptr;
while(index < size) {
// determine type and assign it to value
++index;
}
return value;
}
std::map<std::string, Value*> create_object(std::string &source, size_t &size, int &index) {
std::map<std::string, Value*> object;
while(index < size) {
// the line I think produces the same issue as my original example
object.insert(std::pair<std::string, Value*>(create_key(source, size, index), create_value(source, size, index)));
++index;
}
}