<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Steffen,<br>
<br>
I just tried at one occasion with 'auto&&' and gcc-5. It
worked and didn't trigger the error, although it was inside a
function template. Does that mean that it will also work for other
users/compiler versions or when I make changes in the future?<br>
<br>
Kind regards<br>
Bernd<br>
<br>
On 10/12/2015 06:03 PM, Steffen Müthing wrote:<br>
</div>
<blockquote
cite="mid:0B77F47A-E039-484D-8430-6A7EEEEF5DDE@iwr.uni-heidelberg.de"
type="cite">
<pre wrap="">Hi Atgeirr,
</pre>
<blockquote type="cite">
<pre wrap="">Am 12.10.2015 um 17:16 schrieb Atgeirr Rasmussen <a class="moz-txt-link-rfc2396E" href="mailto:Atgeirr.Rasmussen@sintef.no"><Atgeirr.Rasmussen@sintef.no></a>:
Hi Dune,
I am curious about why you require auto&& (starting with Dune 2.4 according to the web site)?
Are the iterators using proxy objects?
</pre>
</blockquote>
<pre wrap="">
It’s not actually proxy objects, but some grids (typically structured ones like YaspGrid) might just create
a temporary entity every time they are dereferenced. There were some discussions about this topic
(whether to have grid iterators always return a temporary or always return a const ref to an internally
cached entity). In the end we decided to allow for both (one is good for unstructured grids, one is good for
structured grids).
</pre>
<blockquote type="cite">
<pre wrap="">
For general range-for loops I am not sure how I could get const-ness of these (const auto&& would
not be a universal const-reference would it)? I usually prefer to make my objects const if possible
(to prevent myself from making errors), but the auto&& will enable me to modify the range, unless
the range itself is const.
</pre>
</blockquote>
<pre wrap="">
You’re right, const auto&& is something else. auto&& always deduces to the right thing: It creates a variable
of type const Entity& if the iterator returns a const ref, and a variable of type Entity if the returned value is
a temporary (that variable will typically directly be initialized inside the operator* due to RVO and copy elision).
As I said, in our case we are fine w.r.t. to constness, as we either require the iterator to return a const ref or
a temporary. Using const auto& has some subtle performance implications in certain cases, see the discussion
in FS1511 for all the gory details…
Steffen
</pre>
<blockquote type="cite">
<pre wrap="">
Atgeirr
</pre>
<blockquote type="cite">
<pre wrap="">12. okt. 2015 kl. 16.22 skrev Steffen Müthing <a class="moz-txt-link-rfc2396E" href="mailto:steffen.muething@iwr.uni-heidelberg.de"><steffen.muething@iwr.uni-heidelberg.de></a>:
Hi Bernd,
</pre>
<blockquote type="cite">
<pre wrap="">Am 12.10.2015 um 15:50 schrieb Bernd Flemisch <a class="moz-txt-link-rfc2396E" href="mailto:bernd@iws.uni-stuttgart.de"><bernd@iws.uni-stuttgart.de></a>:
Dear Dune,
should I use 'auto&&' or 'const auto&' in a range-based for-loop over the entities of a Dune GridView?
On the one hand, there is
<a class="moz-txt-link-freetext" href="https://www.dune-project.org/doc/doxygen/html/group__GIIteration.html#_details">https://www.dune-project.org/doc/doxygen/html/group__GIIteration.html#_details</a>
which says "**always** use 'auto&&'"
On the other hand, there is
<a class="moz-txt-link-freetext" href="http://conan2.iwr.uni-heidelberg.de/git/pdelab/dune-pdelab/commit/d97c563807cd4f9aaa872dfee57c668eda12db59">http://conan2.iwr.uni-heidelberg.de/git/pdelab/dune-pdelab/commit/d97c563807cd4f9aaa872dfee57c668eda12db59</a>
together with
<a class="moz-txt-link-freetext" href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63506">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63506</a>
which indicates that a GCC bug is triggered when using 'auto&&‘.
</pre>
</blockquote>
<pre wrap="">
yes, it’s all quite a mess: Basically, the standard (and important people like Stroustrup and Sutter) say that you
should *always* use auto&& in a range-based for loop, but GCC has this bug that sometimes causes a compilation
failure if the range-based for appears inside a function template, so you have to use const auto&.
So, the (rather unfortunate) advice is: You should use auto&&, but you can’t if you target current GCC due to a bug in
GCC. In that case, you have to use const auto&.
We should probably update the Doxygen documentation to explain the issue (I forgot about that when I discovered the compiler
b) because we’ll be stuck with the problem for the foreseeable future - the bug is still present in the GCC 6 snapshot from
the beginning of September that I have available on my machine, and the GCC Bugzilla bug hasn’t seen any attention in a long
time. Apart from that, the bug is in GCC 5, which we will have to support for a few years to come…
So I think the documentation needs to explain this issue.
Steffen
</pre>
<blockquote type="cite">
<pre wrap="">
Kind regards
Bernd
--
_______________________________________________________________
Bernd Flemisch phone: +49 711 685 69162
IWS, Universität Stuttgart fax: +49 711 685 60430
Pfaffenwaldring 61 <a class="moz-txt-link-abbreviated" href="mailto:email:bernd@iws.uni-stuttgart.de">email:bernd@iws.uni-stuttgart.de</a>
D-70569 Stuttgart url:www.hydrosys.uni-stuttgart.de
_______________________________________________________________
_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@dune-project.org">Dune@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune">http://lists.dune-project.org/mailman/listinfo/dune</a>
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@dune-project.org">Dune@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune">http://lists.dune-project.org/mailman/listinfo/dune</a>
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@dune-project.org">Dune@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune">http://lists.dune-project.org/mailman/listinfo/dune</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@dune-project.org">Dune@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune">http://lists.dune-project.org/mailman/listinfo/dune</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
_______________________________________________________________
Bernd Flemisch phone: +49 711 685 69162
IWS, Universität Stuttgart fax: +49 711 685 60430
Pfaffenwaldring 61 email: <a class="moz-txt-link-abbreviated" href="mailto:bernd@iws.uni-stuttgart.de">bernd@iws.uni-stuttgart.de</a>
D-70569 Stuttgart url: <a class="moz-txt-link-abbreviated" href="http://www.hydrosys.uni-stuttgart.de">www.hydrosys.uni-stuttgart.de</a>
_______________________________________________________________
</pre>
</body>
</html>