From: Wolfgang Bangerth Date: Thu, 10 Sep 2015 02:36:38 +0000 (-0500) Subject: Avoid a whole lot of warnings. X-Git-Tag: v8.4.0-rc2~447^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1573%2Fhead;p=dealii.git Avoid a whole lot of warnings. These warnings are about accessing elements of a zero sized array as well as comparisons of the form 'i inline Tensor::Tensor (const Tensor &initializer) { - for (unsigned int i=0; i 0) + std::copy (&initializer[0], &initializer[0]+dim, &values[0]); } @@ -893,14 +893,69 @@ operator Tensor<1,dim,Tensor > () const } + +namespace internal +{ + namespace TensorSubscriptor + { + namespace + { + template + ArrayElementType & + subscript (ArrayElementType *values, + const unsigned int i, + dealii::internal::int2type) + { + Assert (i + const ArrayElementType & + subscript (const ArrayElementType *values, + const unsigned int i, + dealii::internal::int2type) + { + Assert (i + ArrayElementType & + subscript (ArrayElementType *, + const unsigned int, + dealii::internal::int2type<0>) + { + Assert(false, ExcMessage("Cannot access elements of an object of type Tensor.")); + static ArrayElementType t; + return t; + } + + + template + const ArrayElementType & + subscript (const ArrayElementType *, + const unsigned int, + dealii::internal::int2type<0>) + { + Assert(false, ExcMessage("Cannot access elements of an object of type Tensor.")); + static ArrayElementType t; + return t; + } + + } + } +} + + template inline typename Tensor::value_type & Tensor::operator[] (const unsigned int i) { - Assert(dim != 0, ExcMessage("Cannot access an object of type Tensor")); - Assert (i()); } @@ -909,9 +964,7 @@ inline const typename Tensor::value_type & Tensor::operator[] (const unsigned int i) const { - Assert(dim != 0, ExcMessage("Cannot access an object of type Tensor")); - Assert (i()); } @@ -942,8 +995,8 @@ inline Tensor & Tensor::operator = (const Tensor &t) { - for (unsigned int i=0; i 0) + std::copy (&t.values[0], &t.values[0]+dim, &values[0]); return *this; } @@ -954,8 +1007,8 @@ inline Tensor & Tensor::operator = (const Tensor &t) { - for (unsigned int i=0; i 0) + std::copy (&t.values[0], &t.values[0]+dim, &values[0]); return *this; }