Commit 32746cc8 authored by Tiago Peixoto's avatar Tiago Peixoto

inference/support/util.hh: use rvalue references

parent dbc8e6f4
...@@ -87,7 +87,7 @@ T log_sum(T a, T b) ...@@ -87,7 +87,7 @@ T log_sum(T a, T b)
} }
template <class Vec, class PosMap, class Val> template <class Vec, class PosMap, class Val>
void remove_element(Vec& vec, PosMap& pos, Val val) void remove_element(Vec& vec, PosMap& pos, Val&& val)
{ {
auto& back = vec.back(); auto& back = vec.back();
auto& j = pos[back]; auto& j = pos[back];
...@@ -98,14 +98,14 @@ void remove_element(Vec& vec, PosMap& pos, Val val) ...@@ -98,14 +98,14 @@ void remove_element(Vec& vec, PosMap& pos, Val val)
} }
template <class Vec, class PosMap, class Val> template <class Vec, class PosMap, class Val>
void add_element(Vec& vec, PosMap& pos, Val val) void add_element(Vec& vec, PosMap& pos, Val&& val)
{ {
pos[val] = vec.size(); pos[val] = vec.size();
vec.push_back(val); vec.push_back(val);
} }
template <class Vec, class PosMap, class Val> template <class Vec, class PosMap, class Val>
bool has_element(Vec& vec, PosMap& pos, Val val) bool has_element(Vec& vec, PosMap& pos, Val&& val)
{ {
size_t i = pos[val]; size_t i = pos[val];
return (i < vec.size() && vec[i] == val); return (i < vec.size() && vec[i] == val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment