const std::vector<int> v = {5, 7, 3, 6, 5, 4, 7, 8, 5, 6};
auto low = std::lower_bound( v.begin(), v.end(), 7);
auto high = std::upper_bound( v.begin(), v.end(), 7);
std::cout << low - v.begin() << " " << high - v.begin();
So when I try to compile this code using the clang++ compiler on my Mac , it returns the output as
10 10
which implies as v.end()
for both high and low although low should be = 1 and high =7 (the number 8). What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…