I see a code below. (it's from caffe source, a deep learning library)
map<int, string> layer_idx_to_layer_name;
layer_idx_to_layer_name[-1] = "input";
What does the second line mean? I guess it's assigning a default value. Is it correct?
I see a code below. (it's from caffe source, a deep learning library)
map<int, string> layer_idx_to_layer_name;
layer_idx_to_layer_name[-1] = "input";
What does the second line mean? I guess it's assigning a default value. Is it correct?
It's doing what it says: Assigning the string "input" to the map entry whose key is -1.
There's no concept of a default value with std::map.
Remember, the key of a std::map doesn't have to be an int (let alone, positive ints) - it can be pretty much any type. std::map isn't a vector.
What requirements must std::map key classes meet to be valid keys?