#include <iostream>
#include <cstdint>
using namespace std;

template <typename T, unsigned int N>
struct buffer {
    int8_t v[N];

    struct proxy {
        int8_t *elem;

    	proxy(int8_t *elem) : elem(elem) {}

        proxy& operator=(T value) {
            // whatever you need...
            *elem = static_cast<T>(value);
            return *this;
        }
        operator T() const {
            // whatever you need... 
            return static_cast<T>(*elem);
        }
    };

    proxy operator[](int i) {
        return proxy{ &v[i] };
    }
};

int main() {
	buffer<double, 1> buf;

	buf[0] = 2.1;
	std::cout << buf[0] << std::endl;

	return 0;
}