*/
AlignedVector();
+ /**
+ * Range constructor.
+ *
+ * @note Unlike std::vector, this constructor uses random-access iterators so
+ * that the copy may be parallelized.
+ *
+ * @dealiiOperationIsMultithreaded
+ */
+ template <
+ typename RandomAccessIterator,
+ typename = std::enable_if_t<std::is_convertible_v<
+ typename std::iterator_traits<RandomAccessIterator>::iterator_category,
+ std::random_access_iterator_tag>>>
+ AlignedVector(RandomAccessIterator begin, RandomAccessIterator end);
+
/**
* Set the vector size to the given size and initializes all elements with
* T().
+template <class T>
+template <typename RandomAccessIterator, typename>
+inline AlignedVector<T>::AlignedVector(RandomAccessIterator begin,
+ RandomAccessIterator end)
+ : elements(nullptr, Deleter(this))
+ , used_elements_end(nullptr)
+ , allocated_elements_end(nullptr)
+ , replicated_across_communicator(false)
+{
+ allocate_and_move(0u, end - begin, end - begin);
+ used_elements_end = allocated_elements_end;
+ dealii::internal::AlignedVectorCopyConstruct<RandomAccessIterator, T>(begin,
+ end,
+ data());
+}
+
+
template <class T>
inline AlignedVector<T>::AlignedVector(const size_type size, const T &init)
: elements(nullptr, Deleter(this))
#include <deal.II/base/aligned_vector.h>
-#include "../tests.h"
+#include <deque>
+#include "../tests.h"
void
test()
b.push_back(27);
a.insert_back(b.begin(), b.end());
+ // Check the range constructor with and without conversion.
+ {
+ VEC c(b.begin(), b.end());
+ AssertThrow(c == b, ExcInternalError());
+
+ std::vector<int> temp(b.begin(), b.end());
+ VEC d(temp.begin(), temp.end());
+ AssertThrow(c == d, ExcInternalError());
+ }
+
+ // Check the range constructor with a random-access iterator which is not
+ // contiguous
+ {
+ // Use a large enough deque to guarantee that we have multiple blocks
+ std::deque<unsigned int> temp(8192);
+ std::iota(temp.begin(), temp.end(), 0u);
+
+ VEC e(temp.begin(), temp.end());
+ AssertThrow(std::equal(e.begin(), e.end(), temp.begin()),
+ ExcInternalError());
+ }
+
deallog << "Insertion: ";
for (unsigned int i = 0; i < a.size(); ++i)
deallog << a[i] << ' ';