|
Boost Users : |
Subject: [Boost-users] copy constructor for derived boost::multi_array
From: HweeKuan Lee (hweekuan_at_[hidden])
Date: 2009-08-24 21:46:20
i am having problems compiling class derived from boost::multi_array. the copy constructor does not compile. as i understand, the usual copy constructor for derived class can be implemented as in line 12 in the code below. however, can't do the same for boost::multi_array at line 21. lots of compile error, i extracted a small part of it below
1 #include <boost/multi_array.hpp>
2
3 // ------------------------------------------
4 template<class V> struct base {
5 base(int y) : u(y ) { }
6 base(const base<V>& b) : u(b.u) { }
7 int u;
8 };
9
10 template<class V> struct derived : public base<V> {
11 derived(int y) : base<V>(y) { }
12 derived(const derived<V>& d) : base<V>(d) { }
13 };
14 // ------------------------------------------
15 template<class V, unsigned int D>
16 struct my_multi : public boost::multi_array<V,D> {
17
18 template<class extent_type>
19 my_multi(const extent_type& e) : boost::multi_array<V,D>(e) { }
20
21 my_multi(const my_multi<V,D>& t) : boost::multi_array<V,D>(t) { }
22 };
23 // ------------------------------------------
24 int main () {
25 derived<int> d(1.0);
26 derived<int> e(d); // ok
27
28 my_multi<int,2> mm0(boost::extents[3][4]);
29 mm0[0][0] = 6; // ok
30 my_multi<int,2> mm1(mm0);
31 }
--------------
extracted compile error:
bmulti.C:21: instantiated from 'my_multi<V, D>::my_multi(const my_multi<V, D>&) [with V = int, unsigned int D = 2u]'
bmulti.C:30: instantiated from here
/opt/local/include/boost/multi_array/collection_concept.hpp:44: error: 'struct my_multi<int, 2u>' has no member named 'swap'
bmulti.C:21: instantiated from 'my_multi<V, D>::my_multi(const my_multi<V, D>&) [with V = int, unsigned int D = 2u]'
bmulti.C:30: instantiated from here
/opt/local/include/boost/multi_array/algorithm.hpp:56: error: cannot convert 'boost::detail::multi_array::const_sub_array<int, 1ul, const int*>' to 'long unsigned int' in assignment
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net