Skip to content

Instantly share code, notes, and snippets.

@pedrovanzella
Created February 26, 2018 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrovanzella/9fc0161cac6c29b38a0d8e8838e7b619 to your computer and use it in GitHub Desktop.
Save pedrovanzella/9fc0161cac6c29b38a0d8e8838e7b619 to your computer and use it in GitHub Desktop.
class Memory {
public:
Memory(std::array<uint8_t, 1024> b) { buff_ = std::move(b); }
uint16_t& operator[](uint16_t addr) {
return (buff_[addr] << 8) + buff_[addr + 1]; // This doesn't work
// cannot bind non-const lvalue reference of type ‘uint16_t& {aka short unsigned int&}’ to an rvalue of type ‘uint16_t {aka short unsigned int}’
}
private:
std::array<uint8_t, 1024> buff_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment