You could use std::numeric_limits<size_t>::max()
for elements that was not found. It is a valid value, but it is impossible to create container with such max index. If std::vector
has size equal to std::numeric_limits<size_t>::max()
, then maximum allowed index will be (std::numeric_limits<size_t>::max()-1)
, since elements counted from 0.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…