Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does list/map return when insert failed?

when insert new element to list/map, it returns the iterator pointed to the newly added element.
But if insert failed, what does list/map return? I have read the references, when failed, list/map will not throw a exception.

like image 799
pengdu Avatar asked Mar 26 '26 00:03

pengdu


1 Answers

map::insert returns pair of iterator and bool value. If insertion fails bool value is set to false.

like image 70
ks1322 Avatar answered Mar 28 '26 15:03

ks1322