Modernes C++ programmieren

Okt 23, 2024

lst-0746-godb.cpp

//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/h6nrPYWfM 
#include <array>
#include <iostream>
int main() {
    std::array ports { 80, 443  };          // array<int>
    auto [ http, https ] = ports;           // deklariert Variablen und bindet sie
    std::cout << http << " " << https << "\n";
    auto const& [ rhttp, rhttps ] = ports;  // Referenz und const sind möglich
    std::cout << rhttp << " " << rhttps << "\n";
}