#include <iostream>

struct foo {
    int x;
    int y;
    int z;
};

struct foo_wrapper {
        foo &ref;

        foo_wrapper( foo &f ) : ref( f ) {}
        int &operator[]( std::size_t rhs ) {
           switch(rhs) {
           case 0U:
               return ref.x;
           case 1U:
               return ref.y;
           case 2U:
               return ref.z;
           default:
               return *(&(ref.z) + rhs - 2U);
           }
        }
 };

foo_wrapper wrap( foo &ff )
{
	return foo_wrapper( ff );
}

int main() {
    foo f;
    wrap( f )[1] = 123;
    std::cout << f.y << std::endl;
}