From 31267675b960fb4020af12f6b2479eaf040a3b74 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 27 Feb 2015 19:32:27 +0000 Subject: [PATCH] Small cleanup in containers utils --- src/containers.hh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/containers.hh b/src/containers.hh index 6f151680..56e5fc1f 100644 --- a/src/containers.hh +++ b/src/containers.hh @@ -86,14 +86,17 @@ FilteredContainer filtered(Container&& container, Filter filt return FilteredContainer(container, std::move(filter)); } +template +using TransformedResult = decltype(std::declval()(*std::declval())); + template struct TransformedIterator : std::iterator()(*std::declval()))>::type> + typename std::remove_reference>::type> { TransformedIterator(Transform transform, Iterator it) : m_it(std::move(it)), m_transform(std::move(transform)) {} - auto operator*() -> decltype(std::declval()(*std::declval())) { return m_transform(*m_it); } + auto operator*() -> TransformedResult { return m_transform(*m_it); } TransformedIterator& operator++() { ++m_it; return *this; } TransformedIterator operator++(int) { auto copy = *this; ++m_it; return copy; }