Skip to main content
2 votes
0 answers
156 views

I have a program that works as expected if compiled by GCC, but behaves weirdly after porting to Visual Studio. The program throws an exception from noexcept(false) destructor (I know that it is a bad ...
Fedor's user avatar
  • 25.7k
2 votes
3 answers
437 views

I am new to C++, I came from Python where there are constructors but no destructors. What is the point of them if the memory is automatically freed when the object goes out of scope ?
Amogus124's user avatar
4 votes
1 answer
166 views

Does Rust have any rules regarding calling drop on arrays? Or vectors? E.g. in C++ desctruction order of array elements is from last to first (opposite to construction order) while in Rust it seems ...
PiotrNycz's user avatar
  • 25.2k
4 votes
1 answer
198 views

C++26 will introduce function contract specifiers, which are contract assertions associated with a function to express and check that function's pre- and post- conditions. If enforced, contract ...
Eternal's user avatar
  • 3,134
17 votes
1 answer
1k views

I have a program where I allocated a lot of data and used multiple libraries. I have a cleanup procedure (can be a function, label, setjmp, or just a section of code) that frees allocated memory and ...
Omar Ahmed's user avatar
2 votes
3 answers
169 views

In Effective C++, by Scott Meyers, item 8, there is a suggestion to wrap (using RAII) an object that has a close method that may throw, to automatically call close in the destructor, but since ...
luczzz's user avatar
  • 446
0 votes
0 answers
58 views

My code is below: class GrandParent { public: GrandParent() {} virtual ~GrandParent() {} int grandparent_data = 100; }; class Parent1 : virtual public GrandParent { public: Parent1() {}...
xxllxx666's user avatar
  • 383
3 votes
1 answer
276 views

In C++, why can't a derived class directly and explicitly call the destructor of its base class without using a scope resolution operator? I've heard that in C++, all destructors are processed by the ...
ValExi's user avatar
  • 141
18 votes
1 answer
179 views

I'm working on modernizing an older C++ code base that contains a simple graph structure. It originally looked like the following: struct node_value_t { ... }; struct dag_node { std::vector<...
Magnus Man's user avatar
9 votes
1 answer
373 views

I tried to match on a generic Result<&mut T, T> inside of a const fn, but the compiler did not let me. It would require being able to drop the value at the end of the scope, which is ...
1uigii's user avatar
  • 94
-1 votes
1 answer
125 views

Take this very simple class. The main() function just creates an object of it. Even though the constructor and destructor don't have an implementation here. My assumption is that the constructor will ...
Engineer999's user avatar
  • 4,169
0 votes
0 answers
73 views

I am thinking about stack unwinding when an exception is thrown here. In the below simple example, when throw 505 is executed, from what I understand, the stack starts to unwind until it finds the ...
Engineer999's user avatar
  • 4,169
1 vote
0 answers
87 views

Is the following undefined behavior or is it well defined? calling a member function on an object. e.g. mystruct.method() which triggers the destruction of the object. For example, the object is a ...
Daniel's user avatar
  • 391
0 votes
1 answer
111 views

My code is: #include <stdlib.h> #include <stdint.h> #include <string.h> class Base { public: Base(uint32_t len) : len_(len) { buf_ = (char *)malloc(len_ * ...
xxllxx666's user avatar
  • 383
2 votes
1 answer
112 views

The base class and its derived class have different destructor names, so how is overriding possible? Could you explain what happens when a destructor is declared as a virtual function?
Code_JP's user avatar
  • 51

15 30 50 per page
1
2 3 4 5
216