Dear all, This still seems to be a problem that every once in a while someone tries to solve and then stops. It's my turn again... I'm trying to make a wrapper template class for 1,2,...8-dimensional images whose values can be char,short,...double to store brain image statistics. I had a go at this before and followed the suggestions described here http://lists.boost.org/boost-users/2009/08/50732.php What I now have is a class bisArray: ... template<typename T> class bisArray: public bisObject { typedef boost::variant < boost::multi_array_ref<T, 1>, boost::multi_array_ref<T, 2>, boost::multi_array_ref<T, 3>, boost::multi_array_ref<T, 4>, boost::multi_array_ref<T, 5>, boost::multi_array_ref<T, 6>, boost::multi_array_ref<T, 7>, boost::multi_array_ref<T, 8>, boost::multi_array_ref<T, 9> > bisArray_t; bisArray_t _bisArray; ... and a class bisImage, which has a bisArray as well as a pointer to the data as read from file (1-dimensional structure): ... template<typename T> class bisImage: public bisObject { public: /** Constructor using existing array data Reformats array as bisImage */ bisImage ( T* _data, size_t _dimensions, std::vector<size_t> _sizes ): data(_data), dimensions(_dimensions) { this.storage=bisArray<T>( _data, _dimensions, _sizes); this.dummy = T(); } ... When I try to initialise an image read from file using ... bisImage<unsigned char> newimage=bisImage<unsigned char> ((unsigned char *)testimage->data, ndim, dims); ... I get, as the first of many errors, this message bisimage.hpp|33|error: no matching function for call to ‘canabis::bisArray<unsigned char>::bisArray()’| That seems to suggest that I call an empty (default) constructor, which I don't do *anywhere* Has anyone ever tried to do something similar? Or do you have any thought about what I am doing wrong here? Is it multi_array complaining or variants? Many thanks Alle Meije
Hello, Alle 2010/11/8 Alle Meije Wink <a.m.wink@gmail.com>
What I now have is a class bisArray: ... template<typename T> class bisArray: public bisObject { typedef boost::variant < boost::multi_array_ref<T, 1>, boost::multi_array_ref<T, 2>, boost::multi_array_ref<T, 3>, boost::multi_array_ref<T, 4>, boost::multi_array_ref<T, 5>, boost::multi_array_ref<T, 6>, boost::multi_array_ref<T, 7>, boost::multi_array_ref<T, 8>, boost::multi_array_ref<T, 9> > bisArray_t; bisArray_t _bisArray; ...
and a class bisImage, which has a bisArray as well as a pointer to the data as read from file (1-dimensional structure): ...
template<typename T>
class bisImage: public bisObject {
public:
/** Constructor using existing array data Reformats array as bisImage */ bisImage ( T* _data, size_t _dimensions, std::vector<size_t> _sizes ): data(_data), dimensions(_dimensions) {
This code (or You) comes from java or C#, doesn't it? ;-) In C++ it is supposed to be this->[...] instead of this.[...] Second thing: the member storage is initialized with the default constructor (which in this case does not exist => error ), and then assigned (below). I suggest a change to: bisImage([...]) : [...], storage( _data, _dimensions, _size ) { [...] and remove the assignment from the body of the constructor Note also: I have read in many places, that you should not use names beginning with an underscore (_), because they are reserved for compiler/library implementation. One of those places was Herb Sutter's gotw series.
this.storage=bisArray<T>( _data, _dimensions, _sizes); this.dummy = T(); }
...
When I try to initialise an image read from file using ... bisImage<unsigned char> newimage=bisImage<unsigned char> ((unsigned char *)testimage->data, ndim, dims); ...
I get, as the first of many errors, this message bisimage.hpp|33|error: no matching function for call to ‘canabis::bisArray<unsigned char>::bisArray()’|
Good lock with Your work on this! Regards, Kris
participants (2)
-
Alle Meije Wink
-
Krzysztof Czainski