@@ -45,30 +45,33 @@ template <typename _Scalar> struct ContactMapTpl {
4545 }
4646
4747 bool getContactState (std::string_view name) const {
48- auto id = std::find (contact_names_.begin (), contact_names_.end (), name);
49- if (id == contact_names_.end ()) {
48+ auto it = std::find (contact_names_.begin (), contact_names_.end (), name);
49+ if (it == contact_names_.end ()) {
5050 ALIGATOR_RUNTIME_ERROR (" Contact name does not exist in this map!" );
5151 }
5252
53- return contact_states_[id - contact_names_.begin ()];
53+ const auto index = size_t (it - contact_names_.begin ());
54+ return contact_states_[index];
5455 }
5556
5657 const Vector3s &getContactPose (std::string_view name) const {
57- auto id = std::find (contact_names_.begin (), contact_names_.end (), name);
58- if (id == contact_names_.end ()) {
58+ auto it = std::find (contact_names_.begin (), contact_names_.end (), name);
59+ if (it == contact_names_.end ()) {
5960 ALIGATOR_RUNTIME_ERROR (" Contact name does not exist in this map!" );
6061 }
6162
62- return contact_poses_[id - contact_names_.begin ()];
63+ const auto index = size_t (it - contact_names_.begin ());
64+ return contact_poses_[index];
6365 }
6466
6567 void setContactPose (std::string_view name, const Vector3s &ref) {
66- auto id = std::find (contact_names_.begin (), contact_names_.end (), name);
67- if (id == contact_names_.end ()) {
68+ auto it = std::find (contact_names_.begin (), contact_names_.end (), name);
69+ if (it == contact_names_.end ()) {
6870 ALIGATOR_RUNTIME_ERROR (" Contact name does not exist in this map!" );
6971 }
7072
71- contact_poses_[id - contact_names_.begin ()] = ref;
73+ const auto index = size_t (it - contact_names_.begin ());
74+ contact_poses_[index] = ref;
7275 }
7376
7477 std::vector<std::string> contact_names_;
0 commit comments