Commit d035d06f authored by Roland Levillain's avatar Roland Levillain
Browse files

Small improvements in mln::util::tracked_ptr.

	* mln/util/tracked_ptr.hh
	(mln::util::tracked_ptr<T>::tracked_ptr(T*))
	(mln::util::tracked_ptr<T>::operator=(T*))
	(mln::util::tracked_ptr<T>::run_() const):
	Remove useless typedefs.
	(mln::util::tracked_ptr<T>::operator=(const tracked_ptr<T>&))
	(mln::util::tracked_ptr<T>::operator=(T*))
	(mln::util::operator<<(std::ostream& ostr, const tracked_ptr<T>&)):
	Check invariants in more places.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4579 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a517df64
2009-09-29 Roland Levillain <roland@lrde.epita.fr>
Small improvements in mln::util::tracked_ptr.
* mln/util/tracked_ptr.hh
(mln::util::tracked_ptr<T>::tracked_ptr(T*))
(mln::util::tracked_ptr<T>::operator=(T*))
(mln::util::tracked_ptr<T>::run_() const):
Remove useless typedefs.
(mln::util::tracked_ptr<T>::operator=(const tracked_ptr<T>&))
(mln::util::tracked_ptr<T>::operator=(T*))
(mln::util::operator<<(std::ostream& ostr, const tracked_ptr<T>&)):
Check invariants in more places.
2009-09-29 Roland Levillain <roland@lrde.epita.fr>
 
Add a dummy operator< to mln::util::multi_site<P>.
// Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -148,8 +149,6 @@ namespace mln
tracked_ptr<T>::tracked_ptr(T* ptr) :
ptr_(ptr)
{
typedef std::set<tracked_ptr<T>*> holders_t;
if (ptr == 0)
holders_ = 0;
else
......@@ -187,6 +186,7 @@ namespace mln
// If ptr == 0, holders_ == 0 so we cannot insert anything in it.
if (holders_ != 0)
holders_->insert(this);
mln_invariant(run_());
return *this;
}
......@@ -194,8 +194,6 @@ namespace mln
inline
tracked_ptr<T>& tracked_ptr<T>::operator=(T* ptr)
{
typedef std::set<tracked_ptr<T>*> holders_t;
mln_invariant(run_());
if (ptr == ptr_)
// no-op
......@@ -209,6 +207,7 @@ namespace mln
holders_ = new holders_t;
holders_->insert(this);
}
mln_invariant(run_());
return *this;
}
......@@ -223,8 +222,6 @@ namespace mln
inline
bool tracked_ptr<T>::run_() const
{
typedef std::set<tracked_ptr<T>*> holders_t;
mln_invariant((ptr_ && holders_) || (! ptr_ && ! holders_));
if (ptr_ == 0)
return true;
......@@ -264,6 +261,7 @@ namespace mln
{
typedef std::set<tracked_ptr<T>*> holders_t;
mln_invariant(tp.run_());
ostr << "tracked_ptr @ " << (&tp)
<< " { ptr = " << tp.ptr_
<< " / holders = ";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment