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; }