#include "stdafx.h" #includeusing namespace std; namespace { volatile uint8_t &memory(const uint16_t loc) { return *reinterpret_cast (loc); } struct VIC_II { static constexpr uint16_t COLOR = 0xd020; volatile uint8_t &border() { return memory(COLOR); } volatile uint8_t& display(const uint8_t col, const uint8_t row) { return memory(1024 + col + row * 40); } auto test() { return std::make_tuple (1, 2, 3); } }; } int main() { const auto le = [](uint8_t i) {cout << i << endl; }; le(3); VIC_II vic; vic.border() = 1; vic.border() = 2; memory(1024) = 'a'; vic.display(1, 2) = 'b'; // destructuring inside if does not work in VS 2015 if ( auto [s1, s2, s3] = vic.test();s1==1) { } return 0; }
Sunday, September 25, 2016
volatile, reinterpre_case, constexpr, lambda and destructuring in C++14 and 17
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment