From f82a2e22a17a4d8746528f92370a425e506fed21 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Feb 2013 19:58:07 +0100 Subject: [PATCH] Containers utils: use Container&& in order to accept temporaries --- src/utils.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils.hh b/src/utils.hh index 1e20ff34..8c52f7b6 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -137,27 +137,27 @@ struct ReversedContainer }; template -ReversedContainer reversed(Container& container) +ReversedContainer reversed(Container&& container) { return ReversedContainer(container); } template -auto find(Container& container, const T& value) -> decltype(container.begin()) +auto find(Container&& container, const T& value) -> decltype(container.begin()) { return std::find(container.begin(), container.end(), value); } template -auto find_if(Container& container, T op) -> decltype(container.begin()) +auto find_if(Container&& container, T op) -> decltype(container.begin()) { return std::find_if(container.begin(), container.end(), op); } template -bool contains(const Container& container, const T& value) +bool contains(Container&& container, const T& value) { return (not container.empty()) and find(container, value) != container.end(); }