template<class T, class U> inline bool operator!=(smart_ptr<T> & a, smart_ptr<U> & b) { return a.get() != b.get(); }
inline void swap (smart_ptr<T> &pt, smart_ptr<T> &pt2) { typename smart_ptr<T>::value_type *ptr = pt.get(); pt = pt2; pt2 = ptr; }
inline std::ptrdiff_t operator- (const smart_ptr<T> &pt, const smart_ptr<T2> &pt2) { return pt.get()- pt2.get(); }
inline bool operator>= (const smart_ptr<T1> &pt1, const smart_ptr<T2> &pt2) { return pt1.get() >= pt2.get(); }
smart_ptr(const smart_ptr<Y> & r, detail::reinterpret_cast_tag) : m_ptr(reinterpret_cast<PointedType*>(r.get())) {}
smart_ptr(const smart_ptr<Y> & r, detail::dynamic_cast_tag) : m_ptr(dynamic_cast<PointedType*>(r.get())) {}
bool uiRunExe(wxFrame* parent,const wxString& path,const wxString& labelOutput, wxWindow* progressDialog,smart_ptr<InterfLogger> extLogger) { _("Elapsed time : "); _("Remaining time : "); _("Close"); _("Cancel"); _("unknown"); wxProgressDialog * progDialog=wxDynamicCast(progressDialog,wxProgressDialog); bool hasOutput=true; processManager* process = new processManager(parent,path); if(extLogger.get()!=NULL) process->AddLogger(extLogger); wxLogInfo(_("Execution d'un programme externe :")); wxLogInfo(path); int processId=wxExecute(path,wxEXEC_ASYNC,process); if(!processId) { wxLogInfo("L'execution du programme a échoué"); delete process; return false; } float percFinish=0; wxDateTime lastProgShow=wxDateTime::UNow(); while(process->IsRunning()) { hasOutput=true; wxMilliSleep(50); while(hasOutput) //&& (!progDialog || progDialog->Update(percFinish*100)) { process->LogOutput(hasOutput,labelOutput,&percFinish); } if(wxDateTime::UNow().GetValue()-lastProgShow.GetValue()>500) { lastProgShow=wxDateTime::UNow(); if(parent) parent->Update(); if(percFinish>99.f) percFinish=99; if(progDialog && !progDialog->Update(percFinish*100)) { wxKillError killerror=wxProcess::Kill(processId,wxSIGKILL); wxLogInfo(_("Execution du programme externe annulé.")); wxLogInfo(_("Réponse du processus :")); switch(killerror) { case wxKILL_OK: // no error wxLogInfo(_("Pas d'erreur.")); break; case wxKILL_BAD_SIGNAL: // no such signal wxLogError(_("Le signal n'existe pas.")); break; case wxKILL_ACCESS_DENIED: // permission denied wxLogError(_("Fermeture du processus non autorisée.")); break; case wxKILL_NO_PROCESS: // no such process wxLogError(_("Ce processus n'existe pas.")); break; case wxKILL_ERROR : // another, unspecified error wxLogError(_("Retour du processus non spécifié")); break; default: wxLogError(_("Retour du processus inconnue")); break; } //Si on supprime le processus maintenant on aura une erreur //Si on ne le supprime pas il y a une fuite mémoire //delete process; return false; } } } // On récupère les derniers messages wxMilliSleep(150); process->LogOutput(hasOutput,labelOutput,&percFinish); while(hasOutput) process->LogOutput(hasOutput,labelOutput,&percFinish); delete process; return true; }
void bar(smart_ptr p) { delete p.get(); // expected-note{{Memory is released}} p.get()->foo(); // expected-note{{Calling 'smart_ptr::get'}} }
friend bool operator!= (const smart_ptr &left, nullptr_t) { return left.get() != nullptr; }
friend bool operator!= (nullptr_t, const smart_ptr &right) { return right.get() != nullptr; }
friend bool operator!= (const smart_ptr &left, const smart_ptr &right) { return left.get() != right.get(); }