I am attempting to retrieve a vector's index based on it's value using std::upper_bound
. For some reason though, the following code sets tmpKey
equal to 2
vs my expected value of 1
. Does anything stick out as being horribly wrong?
int main()
{
float time = 30.0000000;
std::vector<float> positionKeyTimes = { 0.000000000, 30.0000000 };
auto it = std::upper_bound(positionKeyTimes.begin(), positionKeyTimes.end(), time);
auto tmpKey = (size_t)(it - positionKeyTimes.begin());
std::cout << tmpKey << "\n";
std::cin.get();
}