I am working with a microcontroller and I can only statically allocate an array up to a certain size at a fixed address in flash ram. If the required size exceeds the maximum size, I'll also need to allocate a second array sized to the difference at another fixed address.
unsigned char buffer[BUFF_MAX]; // allocated on free SRAM at 0x1000#ifdef CONF_BUFF_SIZE > BUFF_MAX unsigned char buffer2[BUFF_MAX-CONF_BUFF_SIZE]; // allocated on 0xF000#endif// lots of yuck and muck with indexing and switching addresses
I would like to convert the code over to modern C++ (c++2x). I would also like to iterate and index over the two buffers as if it were one contiguous array without explicitly calculating the index and switching arrays. How do I achieve this in idiomatic modern C++?
buffer[1000] = 0xFE; // modifying memory in "buffer2"