C ++ 11では、以下に関して定義された動作はありますか?(つまり、a = 1、2を実行するか、未定義です)
void somefunc(int a, int b) {
std::cout << a << b << std::endl;
}
int i = 0;
somefunc(++i, ++i)
または私は書くべきです:
int i = 0;
int a = ++i;
int b = ++i;
somefunc(a, b);
私が尋ねる理由は、オプションのファイルを解析していて、ある状況ではキーと値のペアを作成したいからです。そして、次のような機能があります。
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;
}
}