#1398 Replace deprecated auto_ptr by unique_ptr
Metadata
Property | Value |
---|---|
Reported by | Christoph Grüninger (gruenich@iws.uni-stuttgart.de) |
Reported at | Dec 15, 2013 21:07 |
Type | Bug Report |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Christian Engwer (christi@conan.iwr.uni-heidelberg.de) |
Last edited at | Sep 8, 2014 20:06 |
Closed by | Christian Engwer (christi@conan.iwr.uni-heidelberg.de) |
Closed at | Sep 8, 2014 20:06 |
Closed in version | 3.0 |
Resolution | Fixed |
Comment |
Description
C++11 deprecated auto_ptr [1] and introduced its replacement unique_ptr. Dune uses auto_ptr in dune/common/singleton.hh for compatibility reasons. Last time I tried Clang 3.4-svn annoyingly warned about its deprecation.
We decided to require GCC 4.4 or newer after Dune 2.3. Luckily, unique_ptr was just introduces in GCC 4.4 [2].
[1] http://en.wikipedia.org/wiki/Auto_ptr [2] http://gcc.gnu.org/gcc-4.4/changes.html
After the release it is time to replace auto_ptr. Following patch does the job:
--- a/dune/common/singleton.hh +++ b/dune/common/singleton.hh @@ -53,7 +53,7 @@ namespace Dune class Singleton { /** @brief Smartpointer to the instance. */
- static std::auto_ptr instance_;
- static std::unique_ptr instance_; protected: /* @brief Private constructor. */ Singleton(){} @@ -70,13 +70,13 @@ namespace Dune static T& instance() { if(instance_.get() == 0)
-
instance_ = std::auto_ptr<T>(new T());
-
instance_ = std::unique_ptr<T>(new T()); return *instance_;
} };
template
- typename std::auto_ptr Singleton::instance_;
- typename std::unique_ptr Singleton::instance_;
} // namespace Dune