Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Auto align of toolbar by frame width Pin
akhil_sudheesh13-Mar-14 19:55
akhil_sudheesh13-Mar-14 19:55 
AnswerRe: Auto align of toolbar by frame width Pin
Rage14-Mar-14 0:07
professionalRage14-Mar-14 0:07 
AnswerRe: Auto align of toolbar by frame width Pin
Rage14-Mar-14 0:15
professionalRage14-Mar-14 0:15 
GeneralRe: Auto align of toolbar by frame width Pin
akhil_sudheesh16-Mar-14 21:29
akhil_sudheesh16-Mar-14 21:29 
Questionstd::shared_ptr causing C4150 warning even if custom deleter is used in Visual C++ 2012 [Solved] Pin
Elerian6-Mar-14 10:17
Elerian6-Mar-14 10:17 
AnswerRe: std::shared_ptr causing C4150 warning even if custom deleter is used in Visual C++ 2012 Pin
«_Superman_»6-Mar-14 14:24
professional«_Superman_»6-Mar-14 14:24 
GeneralRe: std::shared_ptr causing C4150 warning even if custom deleter is used in Visual C++ 2012 Pin
Elerian7-Mar-14 8:10
Elerian7-Mar-14 8:10 
AnswerRe: std::shared_ptr causing C4150 warning even if custom deleter is used in Visual C++ 2012 Pin
Elerian7-Mar-14 8:20
Elerian7-Mar-14 8:20 
Hello again,

I now know what is causing the "problem" and will explain it.

Example code:
XML
class MyIncompleteType; // forward declaration
std::shared_ptr<MyIncompleteType> y(myAllocate(), myFree);
y.reset(); // this works without warning (and calls myFree)
y = nullptr; // this gives me warning C4150


The second parameter to the shared_ptr constructor (myFree) is used to create a specialized a custom deleter template which calles myFree if the object pointed to by shared_ptr has to be deleted.

y.reset(); invokes the custom delimiter and sets the shared_ptr to empty (which is

y = nullptr; initialized the shared_ptr with a new pointer to an object uf MyIncompleteType which is actually nullptr, but a standard deleter is created which causes to C4150 warning because it would delete the object using 'delete' (which is not going to happen because the new pointer is nullptr).

So if you have to reset a shared_ptr of an incomplete type you simply have to use the reset() method.

Assigning a new value to the shared_ptr will also assign a new deleter and if you assign a nullptr it will be boxed and the shared_ptr created will use a default deleter which causes the warning C4150.

Andreas
QuestionThe destructor of MFC application [Solved] Pin
econy6-Mar-14 7:02
econy6-Mar-14 7:02 
AnswerRe: The destructor of MFC application Pin
David Crow6-Mar-14 7:09
David Crow6-Mar-14 7:09 
GeneralRe: The destructor of MFC application Pin
econy6-Mar-14 8:41
econy6-Mar-14 8:41 
GeneralRe: The destructor of MFC application Pin
jeron16-Mar-14 9:15
jeron16-Mar-14 9:15 
GeneralRe: The destructor of MFC application Pin
econy6-Mar-14 10:14
econy6-Mar-14 10:14 
GeneralRe: The destructor of MFC application Pin
jeron16-Mar-14 10:50
jeron16-Mar-14 10:50 
AnswerRe: The destructor of MFC application Pin
«_Superman_»6-Mar-14 14:30
professional«_Superman_»6-Mar-14 14:30 
GeneralRe: The destructor of MFC application Pin
econy7-Mar-14 5:15
econy7-Mar-14 5:15 
Questionso confused. Should I learn Android development? if so, where should I start? Pin
Falconapollo6-Mar-14 4:51
Falconapollo6-Mar-14 4:51 
AnswerRe: so confused. Should I learn Android development? if so, where should I start? Pin
Orjan Westin6-Mar-14 5:36
professionalOrjan Westin6-Mar-14 5:36 
GeneralRe: so confused. Should I learn Android development? if so, where should I start? Pin
Falconapollo6-Mar-14 14:44
Falconapollo6-Mar-14 14:44 
AnswerRe: so confused. Should I learn Android development? if so, where should I start? Pin
David Crow6-Mar-14 7:19
David Crow6-Mar-14 7:19 
GeneralRe: so confused. Should I learn Android development? if so, where should I start? Pin
Falconapollo6-Mar-14 14:45
Falconapollo6-Mar-14 14:45 
AnswerRe: so confused. Should I learn Android development? if so, where should I start? Pin
charlieg6-Mar-14 15:15
charlieg6-Mar-14 15:15 
GeneralRe: so confused. Should I learn Android development? if so, where should I start? Pin
Falconapollo6-Mar-14 15:17
Falconapollo6-Mar-14 15:17 
GeneralRe: so confused. Should I learn Android development? if so, where should I start? Pin
charlieg6-Mar-14 15:46
charlieg6-Mar-14 15:46 
GeneralRe: so confused. Should I learn Android development? if so, where should I start? Pin
Falconapollo6-Mar-14 16:34
Falconapollo6-Mar-14 16:34 

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.