top | item 46184067 (no title) Gupie | 2 months ago Open a file in the constructor, close it in the destructor. RAII with 0 allocations. discuss order hn newest dh2022|2 months ago std::vector<int> allocated and freed on the stack will allocate an array for its int’s on the heap… usefulcat|2 months ago I've heard that MSVC does (did?) that, but if so that's an MSVC problem. gcc and clang don't do that.https://godbolt.org/z/nasoWeq5M load replies (1) Gupie|2 months ago Sure, but my point was that RAII doesn't need to involve the heap. Another example would be acquiring abd releasing a mutex.
dh2022|2 months ago std::vector<int> allocated and freed on the stack will allocate an array for its int’s on the heap… usefulcat|2 months ago I've heard that MSVC does (did?) that, but if so that's an MSVC problem. gcc and clang don't do that.https://godbolt.org/z/nasoWeq5M load replies (1) Gupie|2 months ago Sure, but my point was that RAII doesn't need to involve the heap. Another example would be acquiring abd releasing a mutex.
usefulcat|2 months ago I've heard that MSVC does (did?) that, but if so that's an MSVC problem. gcc and clang don't do that.https://godbolt.org/z/nasoWeq5M load replies (1)
Gupie|2 months ago Sure, but my point was that RAII doesn't need to involve the heap. Another example would be acquiring abd releasing a mutex.
dh2022|2 months ago
usefulcat|2 months ago
https://godbolt.org/z/nasoWeq5M
Gupie|2 months ago