← Back to team overview

dolfin team mailing list archive

Re: [Branch ~dolfin-core/dolfin/main] Rev 4386: Do not initialise MeshFunctions with null pointer.

 

The line

  _values = new T[size];

should take care of that anyway (initializing each item to zero) so
std::fill did not make any difference.

--
Anders


On Wed, Jan 13, 2010 at 09:57:11PM -0000, noreply@xxxxxxxxxxxxx wrote:
> ------------------------------------------------------------
> revno: 4386
> committer: Garth N. Wells <gnw20@xxxxxxxxx>
> branch nick: dolfin-all
> timestamp: Wed 2010-01-13 18:05:35 +0000
> message:
>   Do not initialise MeshFunctions with null pointer.
>
>   Using
>
>     std::fill(_values, _values + size, static_cast<T>(0));
>
>   broke for some T (like std::set).
> modified:
>   dolfin/common/Set.h
>   dolfin/mesh/MeshFunction.h
>
>

> === modified file 'dolfin/common/Set.h'
> --- dolfin/common/Set.h	2010-01-13 12:12:30 +0000
> +++ dolfin/common/Set.h	2010-01-13 18:05:35 +0000
> @@ -34,6 +34,9 @@
>      iterator find(const T& x)
>      { return std::find(_x.begin(), _x.end(), x); }
>
> +    const_iterator find(const T& x) const
> +    { return std::find(_x.begin(), _x.end(), x); }
> +
>      void insert(const T& x)
>      {
>        if( find(x) == this->end() )
> @@ -51,8 +54,9 @@
>
>      void erase(const T& x)
>      {
> -      if (find(x) != _x.end())
> -        _x.erase(find(x));
> +      iterator p = find(x);
> +      if (p != _x.end())
> +        _x.erase(p);
>      }
>
>      void sort()
>
> === modified file 'dolfin/mesh/MeshFunction.h'
> --- dolfin/mesh/MeshFunction.h	2010-01-06 16:00:20 +0000
> +++ dolfin/mesh/MeshFunction.h	2010-01-13 18:05:35 +0000
> @@ -195,7 +195,6 @@
>        _size = size;
>        delete [] _values;
>        _values = new T[size];
> -      std::fill(_values, _values + size, static_cast<T>(0));
>      }
>
>      /// Set all values to given value
>

Attachment: signature.asc
Description: Digital signature