This improves compatibility with std::vector.
*/
const_reference operator[](const size_type index) const;
+ /**
+ * Return a pointer to the underlying data buffer.
+ */
+ pointer
+ data();
+
+ /**
+ * Return a const pointer to the underlying data buffer.
+ */
+ const_pointer
+ data() const;
+
/**
* Return a read and write pointer to the beginning of the data array.
*/
+template <typename T>
+inline typename AlignedVector<T>::pointer
+AlignedVector<T>::data()
+{
+ return data_begin;
+}
+
+
+
+template <typename T>
+inline typename AlignedVector<T>::const_pointer
+AlignedVector<T>::data() const
+{
+ return data_begin;
+}
+
+
+
template <class T>
inline typename AlignedVector<T>::iterator
AlignedVector<T>::begin()
*/
//@{
+ /**
+ * Return a pointer to the underlying data buffer.
+ */
+ pointer
+ data();
+
+ /**
+ * Return a const pointer to the underlying data buffer.
+ */
+ const_pointer
+ data() const;
+
/**
* Make the @p Vector class a bit like the <tt>vector<></tt> class of the
* C++ standard library by returning iterators to the start and end of the
+template <typename Number>
+inline typename Vector<Number>::pointer
+Vector<Number>::data()
+{
+ return values.get();
+}
+
+
+
+template <typename Number>
+inline typename Vector<Number>::const_pointer
+Vector<Number>::data() const
+{
+ return values.get();
+}
+
+
+
template <typename Number>
inline typename Vector<Number>::iterator
Vector<Number>::begin()
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test AlignedVector::data
+
+#include <deal.II/base/aligned_vector.h>
+
+#include "../tests.h"
+
+
+template <typename Container>
+void
+test_array_empty(Container &array)
+{
+ AssertThrow(array.begin() == array.end(), ExcInternalError());
+ AssertThrow(array.end() == array.data(), ExcInternalError());
+ AssertThrow(array.data() == nullptr, ExcInternalError());
+}
+
+
+
+template <typename Container>
+void
+test_array_single(Container &array)
+{
+ AssertThrow(array.begin() + 1 == array.end(), ExcInternalError());
+ AssertThrow(array.end() - 1 == array.data(), ExcInternalError());
+ AssertThrow(array.data() == &array[0], ExcInternalError());
+}
+
+
+
+template <typename T>
+void
+test()
+{
+ AlignedVector<T> array;
+ const AlignedVector<T> &const_array = array;
+ test_array_empty(array);
+ test_array_empty(const_array);
+
+ array.push_back(T{});
+ test_array_single(array);
+ test_array_single(const_array);
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test<int>();
+ test<long double>();
+ test<AlignedVector<double>>();
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test Vector::data
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector.templates.h>
+
+#include "../tests.h"
+
+
+template <typename Container>
+void
+test_array_empty(Container &array)
+{
+ AssertThrow(array.begin() == array.end(), ExcInternalError());
+ AssertThrow(array.end() == array.data(), ExcInternalError());
+ AssertThrow(array.data() == nullptr, ExcInternalError());
+}
+
+
+
+template <typename Container>
+void
+test_array_single(Container &array)
+{
+ AssertThrow(array.begin() + 1 == array.end(), ExcInternalError());
+ AssertThrow(array.end() - 1 == array.data(), ExcInternalError());
+}
+
+
+
+template <typename T>
+void
+test()
+{
+ Vector<T> array;
+ const Vector<T> &const_array = array;
+ test_array_empty(array);
+ test_array_empty(const_array);
+
+ array.reinit(1);
+ test_array_single(array);
+ test_array_single(const_array);
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test<int>();
+ test<double>();
+ test<long double>();
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL::OK