Skip to content
Snippets Groups Projects
Commit f01a1041 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

Deprecate ToUniquePtr.

It was just introduced to allow to  show a
deprecation warning in case someone consumes a
GridFactory::createGrid() into a raw-pointer.
parent 2c560425
No related branches found
No related tags found
1 merge request!912Deprecate ToUniquePtr.
Pipeline #32584 passed
......@@ -37,6 +37,9 @@
- `dune_list_filter` is deprecated and will be removed after Dune 2.8. Use
`list(FILTER ...)` introduced by CMake 3.6 instead.
- `ToUniquePtr` is deprecated and will be removed after Dune 2.8. Use
`std::unique_ptr` or `std::shared_ptr` instead.
- Remove the CMake options `DUNE_BUILD_BOTH_LIBS` and
`DUNE_USE_ONLY_STATIC_LIBS`. Use the default CMake way instead by
setting `BUILD_SHARED_LIBS` accordingly. Building both static
......
......@@ -22,6 +22,8 @@ int main()
using namespace Dune;
TestSuite t;
DUNE_NO_DEPRECATED_BEGIN
{
int* ptr = new int(1);
......@@ -32,10 +34,8 @@ int main()
ToUniquePtr<int> w2 = makeToUnique<int>(2);
// test conversion to pointer
DUNE_NO_DEPRECATED_BEGIN
int* p1 = f1();
A* p2 = g();
DUNE_NO_DEPRECATED_END
delete p1;
delete p2;
......@@ -89,5 +89,8 @@ int main()
std::unique_ptr<int> x0{ f_old() };
std::unique_ptr<int> x1{ f1() };
std::unique_ptr<int> x2 = f1();
DUNE_NO_DEPRECATED_END
return t.exit();
}
......@@ -4,6 +4,8 @@
#ifndef DUNE_TO_UNIQUE_PTR_HH
#define DUNE_TO_UNIQUE_PTR_HH
#warning to_unique_ptr.hh and ToUniquePtr is deprecated. Use std::unique_ptr or std::shared_ptr instead.
#include <memory>
namespace Dune
......@@ -12,6 +14,9 @@ namespace Dune
/// Transfers ownership by cast to any (smart) pointer type. Releases the stored pointer on transfer.
/// NOTE: This is an intermediate solution to switch to std::unique_ptr in later releases smoothly.
/**
* \deprecated ToUniquePtr is deprecated and will be removed after Dune 2.8.
* Use std::unique_ptr or std::shared_ptr instead.
*
* Example of usage:
* ```
* ToUniquePtr<int> f() { return new int(1); }
......@@ -30,7 +35,9 @@ namespace Dune
* ```
**/
template <class T>
class ToUniquePtr
class
[[deprecated("Will be removed after Dune 2.8. Use std::unique_ptr or std::shared_ptr instead.")]]
ToUniquePtr
: public std::unique_ptr<T>
{
using Super = std::unique_ptr<T>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment