#include <iostream>
#include <vector>
using namespace std;
#define METHOD(NAME, ...) auto NAME __VA_ARGS__ -> decltype(m_T.r##NAME) { return m_T.r##NAME; }
template<typename T>
struct Reverse
{
T& m_T;
METHOD(begin());
METHOD(end());
METHOD(begin(), const);
METHOD(end(), const);
};
#undef METHOD
template<typename T>
Reverse<T> MakeReverse (T& t) { return Reverse<T>{t}; }
int main ()
{
vector<int> v = {0, 1, 2, 3, 4, 5};
cout << "\nForward: ";
for(auto& i : v)
cout << i << ", ";
cout << "\nReverse: ";
for(auto& i : MakeReverse(v))
cout << i << ", ";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBNRVRIT0QoTkFNRSwgLi4uKSBhdXRvIE5BTUUgX19WQV9BUkdTX18gLT4gZGVjbHR5cGUobV9ULnIjI05BTUUpIHsgcmV0dXJuIG1fVC5yIyNOQU1FOyB9CnRlbXBsYXRlPHR5cGVuYW1lIFQ+CnN0cnVjdCBSZXZlcnNlCnsKICBUJiBtX1Q7CgogIE1FVEhPRChiZWdpbigpKTsKICBNRVRIT0QoZW5kKCkpOwogIE1FVEhPRChiZWdpbigpLCBjb25zdCk7CiAgTUVUSE9EKGVuZCgpLCBjb25zdCk7Cn07CiN1bmRlZiBNRVRIT0QKCnRlbXBsYXRlPHR5cGVuYW1lIFQ+ClJldmVyc2U8VD4gTWFrZVJldmVyc2UgKFQmIHQpIHsgcmV0dXJuIFJldmVyc2U8VD57dH07IH0KCmludCBtYWluICgpCnsKICB2ZWN0b3I8aW50PiB2ID0gezAsIDEsIDIsIDMsIDQsIDV9OyAKCiAgY291dCA8PCAiXG5Gb3J3YXJkOiAiOwogIGZvcihhdXRvJiBpIDogdikKICAgIGNvdXQgPDwgaSA8PCAiLCAiOwoKICBjb3V0IDw8ICJcblJldmVyc2U6ICI7CiAgZm9yKGF1dG8mIGkgOiBNYWtlUmV2ZXJzZSh2KSkKICAgIGNvdXQgPDwgaSA8PCAiLCAiOwp9Cg==
Forward: 0, 1, 2, 3, 4, 5,
Reverse: 5, 4, 3, 2, 1, 0,