I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.
I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.
DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.
So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far
main.cpp:26:72: error: no member named 'value_type' in 'boost::shared_ptr<DeviceInfo>'
boost::bind(&strcmp, boost::bind(&boost::shared_ptr<DeviceInfo>::value_type::Name, _1), (*pDevice)->Name) == 0) == m_cMonitoredDevices.end()) {
could you post a minimal compilable example?
In any case, your code is almost fine, you're just comparing the result of find_if to the wrong container's end iterator.