Modernes C++ programmieren

Okt 23, 2024

lst-0321-godb.cpp

//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/b9arcEMM1 
constinit auto SZ = 10*1000-1;                 // globale Variable
size_t autoincrement() {
    static constinit size_t i = 0;             // lokale statische Variable
    return i++;
}
class BraitenbergVehicle {
    inline static constinit size_t count_ = 0; // Klassenvariable
public:
    size_t id_;
    BraitenbergVehicle() : id_{++count_} {}
    ~BraitenbergVehicle() { --count_; }
};