--- /dev/null
+Fixed: The function AlignedVector::push_back did not work correctly for
+types that do not provide a default constructor. This is now fixed.
+<br>
+(Martin Kronbichler, 2017/02/22)
if (_end_data == _end_allocated)
reserve (std::max(2*capacity(),static_cast<size_type>(16)));
if (std_cxx11::is_trivial<T>::value == false)
- new (_end_data) T;
- *_end_data++ = in_data;
+ new (_end_data++) T(in_data);
+ else
+ *_end_data++ = in_data;
}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2012 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test for AlignedVector::push_back
+
+#include "../tests.h"
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+
+#include <deal.II/base/aligned_vector.h>
+
+// dummy class without default constructor
+class foo
+{
+public:
+ foo (const unsigned int a) : vec(1, a) {}
+ foo (const foo &bar) : vec(bar.vec) {}
+ foo &operator= (const foo &bar)
+ {
+ vec = bar.vec;
+ return *this;
+ }
+
+ unsigned int element() const
+ {
+ return vec[0];
+ }
+
+private:
+ AlignedVector<unsigned int> vec;
+};
+
+void test ()
+{
+ AlignedVector<foo> vec;
+ vec.push_back(foo(3));
+ vec.resize(2, foo(6));
+ deallog << vec[0].element() << " " << vec[1].element() << std::endl;
+ vec[1] = foo(13);
+ deallog << vec[0].element() << " " << vec[1].element() << std::endl;
+ vec.reserve(3);
+ deallog << vec[0].element() << " " << vec[1].element() << std::endl;
+}
+
+
+
+
+int main()
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.threshold_double(1.e-10);
+
+ test ();
+}
--- /dev/null
+
+DEAL::3 6
+DEAL::3 13
+DEAL::3 13
{
typedef VectorizedArray<Number> vector_t;
// allocate FEEvaluation. This test will test proper alignment
- AlignedVector<FEEvaluation<dim,degree_p+1,degree_p+2,dim,Number> > velocity
- (1, FEEvaluation<dim,degree_p+1,degree_p+2,dim,Number>(data, 0));
+ AlignedVector<FEEvaluation<dim,degree_p+1,degree_p+2,dim,Number> > velocity;
+ velocity.push_back(FEEvaluation<dim,degree_p+1,degree_p+2,dim,Number>(data, 0));
AlignedVector<FEEvaluation<dim,degree_p, degree_p+2,1, Number> > pressure
(1, FEEvaluation<dim,degree_p, degree_p+2,1, Number>(data, 1));
FEEvaluation<dim,degree_p, degree_p+2,1, Number> pressure2(data, 1);