Opened 20 years ago
Closed 15 years ago
#105 closed Feature Requests (wontfix)
Why noncopyable destructor isn't virtual — at Version 5
Reported by: | Owned by: | nobody | |
---|---|---|---|
Milestone: | Component: | None | |
Version: | Boost 1.34.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description (last modified by )
Rule 14 in "Effective C++ 2/e": "Make sure base classes have virtual destructors." But why base class noncopyable doesn't have ?
Change History (5)
comment:2 by , 17 years ago
Logged In: YES user_id=419557 This would be a problem if you used it like this: class A : private boost::noncopyable { /* ... */ }; noncopyable* a = new A; delete a; But noncopyable isn't supposed to be used this way.
comment:3 by , 17 years ago
Logged In: YES user_id=419557 This would be a problem if you used it like this: class A : private boost::noncopyable { /* ... */ }; noncopyable* a = new A; delete a; But noncopyable isn't supposed to be used this way.
comment:4 by , 16 years ago
Logged In: NO one should not use the pointer to a noncopyable object A tyical code should look something like this: class A: private noncopyable { } A* pa = new A(); delete pa; And, the private will make sure that no one can access A through noncopyable interface. So you cannot say: noncopyable* pnc = new A(); it will create an error message like: a.cxx: In function `int main()': a.cxx:11: error: `noncopyable' is an inaccessible base of `A' regards, Sambit
comment:5 by , 15 years ago
Description: | modified (diff) |
---|---|
Reporter: | changed from | to
Resolution: | None → wontfix |
Severity: | → Cosmetic |
Status: | assigned → closed |
Version: | None → release 1.34.0 |
The answer why not is that it would add needless overhead.
Note:
See TracTickets
for help on using tickets.