Skip to content

Commit 8916f51

Browse files
committed
make_iterator: return references to values, not copies
1 parent befeb54 commit 8916f51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/nanobind/make_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ template <typename Iterator> struct iterator_access {
3333
};
3434

3535
template <typename Iterator> struct iterator_key_access {
36-
using result_type = decltype((*std::declval<Iterator &>()).first);
36+
using result_type = const decltype((*std::declval<Iterator &>()).first) &;
3737
result_type operator()(Iterator &it) const { return (*it).first; }
3838
};
3939

4040
template <typename Iterator> struct iterator_value_access {
41-
using result_type = decltype((*std::declval<Iterator &>()).second);
41+
using result_type = const decltype((*std::declval<Iterator &>()).second) &;
4242
result_type operator()(Iterator &it) const { return (*it).second; }
4343
};
4444

0 commit comments

Comments
 (0)