If I override the destructor of my class, can I check if this instance should be killed or sent to the pool? I want to simplify the reuse of obj, the user only needs to free it (or leave it to the compiler), and the destructor will check if it can be reused.
ReusableClass::~ReusableClass() { if (x == 1) { // abort destructor, send to pool } }
As soon as the object's destructor is started, the object is considered dead: 12.4 [class.dtor] paragraph 14:
As soon as the destructor is called for the object, the object no longer exists; ...
Of course not - you would also not have a reference to the object - how could you recycle the object?
, . , , , (, Java) ( ), .
Source: https://habr.com/ru/post/1528839/More articles:I cannot upload vine.co to a WebView, no matter what user address I send. - androidChrome 33 does not allow video capture, although it is allowed in the settings - google-chromeHow to find intersections between two git commits? - githttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1528837/how-do-i-pipe-comm-outputs-to-a-file&usg=ALkJrhgheTje7BEHiwzrPtNCDEc9kEIm-gAmazon AWS - Как изменить частный IP-адрес сетевого интерфейса, связанного с RDS - amazon-web-servicesRequire.js compiler generates inaccurate source codes - requirejsCoffeeScript Compilation: Unexpected IF - javascriptПоиск шаблона в строке в python - pythonUnexpected identifier when using module.exports (Node.js) - node.jsAny way to simulate the motion of a 3D ball in a 2D game using SpriteKit? - 2dAll Articles