Skip to content

Commit 0eccb95

Browse files
mkrzewicmatthiasrichter
authored andcommitted
Forward args to forEach
1 parent 5754457 commit 0eccb95

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Utilities/O2Device/include/O2Device/Utilities.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace internal
8181
{
8282

8383
template <typename I, typename F>
84-
auto forEach(I begin, I end, F function)
84+
auto forEach(I begin, I end, F&& function)
8585
{
8686
using span = gsl::span<const byte>;
8787
using gsl::narrow_cast;
@@ -110,14 +110,14 @@ auto forEach(I begin, I end, F function)
110110
/// Execute user code (e.g. a lambda) on each data block (header-payload pair)
111111
/// returns the function (same as std::for_each)
112112
template <typename F>
113-
auto forEach(O2Message& parts, F function)
113+
auto forEach(O2Message& parts, F&& function)
114114
{
115115
if ((parts.Size() % 2) != 0) {
116116
throw std::invalid_argument(
117117
"number of parts in message not even (n%2 != 0), cannot be considered an O2 compliant message");
118118
}
119119

120-
return internal::forEach(parts.begin(), parts.end(), function);
120+
return internal::forEach(parts.begin(), parts.end(), std::forward<F>(function));
121121
}
122122

123123
}; //namespace o2

0 commit comments

Comments
 (0)