I am trying to use lower_bound() function which is a built-in function in C++ standard library that returns an iterator pointing to the first element in the container whose key is not considered to go before k. My understanding is that is used as follows:
my_map.lower_bound(key)
I have a class SpeedProfile:
#include <stdio.h>
#include <map>
using namespace std;
class SpeedProfile
{
public:
map <int, float> timeSlotMap;
};
and I'm trying to call lower_bound from another class:
vector<SpeedProfile> speedProfiles = isRightDirection ? positiveSpeedProfiles : negativeSpeedProfiles;
time_t t = time(nullptr);
tm* timePtr = localtime(&t);
uint32_t dayOfWeek = timePtr->tm_wday;
SpeedProfile dayProfile = speedProfiles[dayOfWeek];
int secondsPassed = (int) (dateinMillis) / 1000;
float lower_b = dayProfile.timeSlotMap.lower_bound(secondsPassed);
I am getting the following error and I'm not sure how I should proceed.
No viable conversion from 'std::__1::map, std::__1::allocator > >::iterator' (aka '__map_iterator<__tree_iterator, std::__1::__tree_node, void *> *, long> >') to 'float'
Using auto lower_b solves the error warning but I don't think this is the correct way forward.