@dblaikie pointed an issue wherein if you wrote a ranged-based for like this:
for (auto X : enumerate(std::vector<int>{1,2,3})) { }
The vector would be destroyed since the range adapter stored the argument by reference. This patch adds a new template to stl extras called remove_rvalue_reference which is similar to std::remove_reference but only removes rvalue reference. This way, if it is constructed with an rvalue, it will copy the range, but if it is constructed with an lvalue, it will store by reference.
A test is added to verify that it works. The same test was confirmed to segfault before this patch.
Put these as members of enumerate_impl so that they can directly use R? I would alse name them IteratorT and ValueT.
But I don't know that you want to define ValueT this way. Instead, I would use std::iterator_traits<IteratorT>::value_type and std::iterator_traits<IteratorT>::reference which seem like the more formal way to extract this information.
However, this may in turn show that you can't actually nest these yet. But if you want to fix that, I think it will need a much more invasive change. I wouldn't worry with that unless you really want to...