1 // Copyright 2002 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
9 // Jeremy Siek
10 // Andrew Lumsdaine
11 // See http://www.boost.org/libs/multi_array for documentation.
12
13 //
14 // assign_to_array.cpp - multi_array should be constructible from any other
15 // array type in the library.
16 //
17 //
18 #include "generative_tests.hpp"
19 #include <boost/array.hpp>
20 #include <boost/multi_array.hpp>
21 #include <boost/cstdlib.hpp>
22 #include <algorithm>
23 #include <iostream>
24
equal(const int & a,const int & b)25 bool equal(const int& a, const int& b)
26 {
27 return a == b;
28 }
29
30 template <typename ArrayA, typename ArrayB>
equal(const ArrayA & A,const ArrayB & B)31 bool equal(const ArrayA& A, const ArrayB& B)
32 {
33 typename ArrayA::const_iterator ia;
34 typename ArrayB::const_iterator ib = B.begin();
35 for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
36 if (!::equal(*ia, *ib))
37 return false;
38 return true;
39 }
40
41
42 template <typename Array>
access(Array & A,const mutable_array_tag &)43 void access(Array& A, const mutable_array_tag&) {
44
45 assign(A);
46 access(A,const_array_tag());
47 }
48
49 template <typename Array>
access(Array & A,const const_array_tag &)50 void access(Array& A, const const_array_tag&) {
51 typedef boost::multi_array<int,3> array3;
52 array3 acopy(A);
53 BOOST_TEST(::equal(acopy,A));
54 ++tests_run;
55 }
56
57
main()58 int main() {
59 return run_generative_tests();
60 }
61