[Dune] [Dune-Commit] dune-localfunctions r1049 - trunk/dune/localfunctions/common

Markus Blatt markus at dr-blatt.de
Fri Apr 13 16:43:24 CEST 2012


Hey Christoph,

On Fri, Apr 13, 2012 at 03:47:28PM +0200, gruenich at dune-project.org wrote:
> Author: gruenich
> Date: 2012-04-13 15:47:28 +0200 (Fri, 13 Apr 2012)
> New Revision: 1049
> 
> Modified:
>    trunk/dune/localfunctions/common/virtualinterface.hh
> Log:
> Change loop variable type from int to std::size_t to avoid warning. Fixes FS#1068.
> 
> 
> Modified: trunk/dune/localfunctions/common/virtualinterface.hh
> ===================================================================
> --- trunk/dune/localfunctions/common/virtualinterface.hh	2012-04-05 09:55:08 UTC (rev 1048)
> +++ trunk/dune/localfunctions/common/virtualinterface.hh	2012-04-13 13:47:28 UTC (rev 1049)
> @@ -311,7 +311,7 @@
>        const LocalInterpolationVirtualInterfaceBase<DomainType, RangeType>& asBase = *this;
>        asBase.interpolate(VirtualFunctionWrapper<F>(f),outDummy);
>        out.resize(outDummy.size());
> -      for(int i=0; i<outDummy.size(); ++i)
> +      for(std::size_t i=0; i<outDummy.size(); ++i)
>          out[i] = outDummy[i];
>      }
>


IMHO the originally proposed patch was the better fix as it used the
more portable std::vector::size_type and not siz_t.

The fact that on your system and many others (when using the
std::allocator) std::vector::size_type is a std::size_t is an
implementation detail. Usually, the size_type of the container is just
the size_type of the allocator used underneath. There might be
allocators that use a a a different type. Or weired libraries that
prefer ints for no reason ;)

See
e.g. <http://stackoverflow.com/questions/918567/size-t-vs-containersize-type>.


Cheers,

Markus

-- 
Do you need more support with DUNE or HPC in general? 

Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany
Tel.: +49 (0) 160 97590858  Fax: +49 (0)322 1108991658 




More information about the Dune mailing list