Commit c335794d authored by Anton Bukov's avatar Anton Bukov

Improve

parent fd71ee70
...@@ -540,7 +540,7 @@ namespace boolinq { ...@@ -540,7 +540,7 @@ namespace boolinq {
return Linq<S, T>(*this).next(); return Linq<S, T>(*this).next();
} }
T firstOrDefault(std::function<bool(T)> predicate, T defaultValue = T()) const T firstOrDefault(std::function<bool(T)> predicate, T const& defaultValue = T()) const
{ {
try { try {
return where(predicate).next(); return where(predicate).next();
...@@ -549,7 +549,7 @@ namespace boolinq { ...@@ -549,7 +549,7 @@ namespace boolinq {
return defaultValue; return defaultValue;
} }
T firstOrDefault(T defaultValue = T()) const T firstOrDefault(T const& defaultValue = T()) const
{ {
try { try {
return Linq<S, T>(*this).next(); return Linq<S, T>(*this).next();
...@@ -578,7 +578,7 @@ namespace boolinq { ...@@ -578,7 +578,7 @@ namespace boolinq {
return last([](T /*value*/) { return true; }); return last([](T /*value*/) { return true; });
} }
T lastOrDefault(std::function<bool(T)> predicate, T defaultValue = T()) const T lastOrDefault(std::function<bool(T)> predicate, T const& defaultValue = T()) const
{ {
T res = defaultValue; T res = defaultValue;
where(predicate).for_each([&res](T value) { where(predicate).for_each([&res](T value) {
...@@ -587,7 +587,7 @@ namespace boolinq { ...@@ -587,7 +587,7 @@ namespace boolinq {
return res; return res;
} }
T lastOrDefault(T defaultValue = T()) const T lastOrDefault(T const& defaultValue = T()) const
{ {
return lastOrDefault([](T /*value*/) { return true; }, defaultValue); return lastOrDefault([](T /*value*/) { return true; }, defaultValue);
} }
......
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