Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Smart pointers Pin
Pascal Ganaye15-Nov-11 11:32
Pascal Ganaye15-Nov-11 11:32 
GeneralRe: Smart pointers Pin
JackDingler15-Nov-11 11:42
JackDingler15-Nov-11 11:42 
GeneralRe: Smart pointers Pin
Pascal Ganaye15-Nov-11 11:46
Pascal Ganaye15-Nov-11 11:46 
GeneralRe: Smart pointers Pin
JackDingler15-Nov-11 12:01
JackDingler15-Nov-11 12:01 
GeneralRe: Smart pointers Pin
Pascal Ganaye15-Nov-11 21:52
Pascal Ganaye15-Nov-11 21:52 
GeneralRe: Smart pointers Pin
JackDingler16-Nov-11 2:04
JackDingler16-Nov-11 2:04 
GeneralRe: Smart pointers Pin
Erudite_Eric15-Nov-11 22:32
Erudite_Eric15-Nov-11 22:32 
GeneralRe: Smart pointers Pin
Stefan_Lang17-Nov-11 4:37
Stefan_Lang17-Nov-11 4:37 
First, the new C++11 standard does contain smart pointers, and they avoid all of the above problems as well as some that you introduced.

Second, C++11 introduced move-semantics, and thereby the concept of passing ownership to another. Your core-premise of a singular ownership directly interferes with that concept. The ANSI commission didn't introduce this on a whim, they had some very good reasons, so why would you want to counter their efforts?

Third, this...
Pascal Ganaye wrote:
- when an object is freed any other pointer to it get nullified

is a very bad idea! what are other parts of your application supposed to do when the pointer they rely on suddenly got nullified? How can you guarantee that your whole application isn't left in an undefined state because an operation couldn't be completed? This is an obvious concern in a multi-threaded application, but even single-threaded, it may cause big headaches. Sure, you can create a mutex for a pointer to make sure you can complete your operations, but that also means that the owner may not be able to nullify it's own pointer for an unspecified time. That doesn't quite mix with the conceept of ownership.

Fourth, you mention that you know there are smart pointer implementations. Why don't you go have a look at them before implementing a concept of your own? They solve all the problems you listed plus the ones I pointed out above.
GeneralRe: Smart pointers Pin
Pascal Ganaye17-Nov-11 4:59
Pascal Ganaye17-Nov-11 4:59 
GeneralRe: Smart pointers Pin
Stefan_Lang17-Nov-11 5:47
Stefan_Lang17-Nov-11 5:47 
GeneralRe: Smart pointers Pin
Pascal Ganaye18-Nov-11 0:09
Pascal Ganaye18-Nov-11 0:09 
GeneralRe: Smart pointers Pin
Stefan_Lang18-Nov-11 0:28
Stefan_Lang18-Nov-11 0:28 
QuestionCreateFile after CloseHandle Pin
aangerma14-Nov-11 23:49
aangerma14-Nov-11 23:49 
AnswerRe: CreateFile after CloseHandle Pin
User 742933814-Nov-11 23:58
professionalUser 742933814-Nov-11 23:58 
GeneralRe: CreateFile after CloseHandle Pin
aangerma15-Nov-11 0:09
aangerma15-Nov-11 0:09 
AnswerRe: CreateFile after CloseHandle Pin
User 742933815-Nov-11 0:20
professionalUser 742933815-Nov-11 0:20 
GeneralRe: CreateFile after CloseHandle Pin
aangerma15-Nov-11 0:35
aangerma15-Nov-11 0:35 
GeneralRe: CreateFile after CloseHandle Pin
Erudite_Eric15-Nov-11 1:37
Erudite_Eric15-Nov-11 1:37 
GeneralRe: CreateFile after CloseHandle Pin
Vaclav_15-Nov-11 10:45
Vaclav_15-Nov-11 10:45 
GeneralRe: CreateFile after CloseHandle Pin
Erudite_Eric15-Nov-11 21:19
Erudite_Eric15-Nov-11 21:19 
QuestionHide folder in window explorer Pin
MKC00214-Nov-11 22:40
MKC00214-Nov-11 22:40 
AnswerRe: Hide folder in window explorer Pin
Richard MacCutchan14-Nov-11 23:07
mveRichard MacCutchan14-Nov-11 23:07 
GeneralRe: Hide folder in window explorer Pin
MKC00215-Nov-11 21:33
MKC00215-Nov-11 21:33 
GeneralRe: Hide folder in window explorer Pin
Richard MacCutchan15-Nov-11 21:46
mveRichard MacCutchan15-Nov-11 21:46 
Questionconvert double to WCHAR Pin
jkirkerx14-Nov-11 16:32
professionaljkirkerx14-Nov-11 16:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.