<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Dear Dune developers,</p>
    <p>In the year 2017 (it might have been in a developer meeting) we
      decided to "smoothly" transition from raw pointers in
      GridFactory::createGrid() towards std::unique_ptr. This transition
      was done, by introducing an intermediate representation, called
      ToUniquePtr that is actually a std::unique_ptr that additional
      gives a deprecation warning in case this type is converted into a
      raw pointer. This made it possible to have user code still
      working, but with this additional warning so that users have
      enough time to adopt their code.</p>
    <p>On the library site, the GridFactory implementations for own
      grids need to handle these changes in the return type of
      createGrid() directly, since otherwise the interface for
      GridFactories is not fulfilled. <br>
    </p>
    <p>Now, finally, we want to drop this intermediate representation
      (or better: deprecate its usage). For user code this should not
      change anything except that now a cast to a raw pointer does not
      work anymore. Since this is deprecated since 4 years it can be
      expected that user code is adopted. <br>
    </p>
    <p>We propose in
      <a class="moz-txt-link-freetext" href="https://gitlab.dune-project.org/core/dune-common/-/merge_requests/912">https://gitlab.dune-project.org/core/dune-common/-/merge_requests/912</a>
      to replace the class ToUniquePtr with an alias template that
      directly defines the std::unique_ptr. If you have an own
      GridFactory implementation for some grid type, you will get a
      deprecation warning if you use that type alias, but the code
      should still work fine.</p>
    <p>The proper fix to remove this deprecation warning is to return
      directly std::unique_ptr:</p>
    <p><font face="monospace">template <class GridType><br>
        std::unique_ptr<GridType>
        GridFactory<GridType>::createGrid () override;</font></p>
    <p>If you want to support multiple dune releases in a grid
      implementation, you might need to consider three cases now:</p>
    <pre class="code highlight" lang="cpp"><span id="LC1" class="line" lang="cpp"><span class="cp">#if DUNE_VERSION_LT(DUNE_COMMON, 2, 7)</span></span>
<span id="LC2" class="line" lang="cpp"><span class="c1">// no include needed</span></span>
<span id="LC3" class="line" lang="cpp"><span class="cp">#elif DUNE_VERSION_LT(DUNE_COMMON, 2, 8)</span></span>
<span id="LC4" class="line" lang="cpp"><span class="cp">#include <dune/common/to_unique_ptr.hh></span></span>
<span id="LC5" class="line" lang="cpp"><span class="cp">#else </span></span>
<span id="LC6" class="line" lang="cpp"><span class="cp">#include <memory></span></span>
<span id="LC7" class="line" lang="cpp"><span class="cp">#endif</span></span>
<span id="LC8" class="line" lang="cpp"></span>
<span id="LC9" class="line" lang="cpp"><span class="c1">// ...</span></span>
<span id="LC10" class="line" lang="cpp"></span>
<span id="LC11" class="line" lang="cpp"><span class="cp">#if DUNE_VERSION_LT(DUNE_COMMON, 2, 7)</span></span>
<span id="LC12" class="line" lang="cpp">  <span class="n">GridType</span><span class="o">*</span> <span class="n">createGrid </span><span class="p">()</span> <span class="k">override</span>;<span class="p"></span></span>
<span id="LC13" class="line" lang="cpp"><span class="cp">#elif DUNE_VERSION_LT(DUNE_COMMON, 2, 8)</span></span>
<span id="LC14" class="line" lang="cpp">  <span class="n">ToUniquePtr</span><span class="o"><</span><span class="n"></span></span><span id="LC14" class="line" lang="cpp"><span class="n"><span id="LC12" class="line" lang="cpp"><span class="n">GridType</span><span class="o"></span></span></span><span class="o">></span> <span class="n">createGrid </span><span class="p">()</span> <span class="k">override</span>;<span class="p"></span></span>
<span id="LC15" class="line" lang="cpp"><span class="cp">#else </span></span>
<span id="LC16" class="line" lang="cpp">  <span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o"><</span><span class="n">GridType</span><span class="o">></span> <span class="n">createGrid</span><span class="p"> ()</span> <span class="k">override</span>;<span class="p"></span></span>
<span id="LC17" class="line" lang="cpp"><span class="cp">#endif</span></span>

</pre>
    <p>We would like to include this change in the Dune 2.8 release.
      Additionally I would try to update GridFactory implementations in
      core, staging and extension modules to have this proper return
      type. Then, hopefully in the next release, we can get rid of this
      intermediate type ToUniquePtr completely.</p>
    <p>If you have any remarks or see any overlooked complication,
      please comment in the merge request above. At beginning of next
      week I want to merge this, so that there is enough time to update
      all the other modules before the feature freeze date.</p>
    <p>Best regards,<br>
      Simon<br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Dr. Simon Praetorius
Technische Universität Dresden
Institute of Scientific Computing
phone: +49 351 463-34432
mail: <a class="moz-txt-link-abbreviated" href="mailto:simon.praetorius@tu-dresden.de">simon.praetorius@tu-dresden.de</a>
web: <a class="moz-txt-link-freetext" href="https://tu-dresden.de/mn/math/wir/das-institut/beschaeftigte/simon-praetorius">https://tu-dresden.de/mn/math/wir/das-institut/beschaeftigte/simon-praetorius</a></pre>
  </body>
</html>