
Dear Kris, thanks for your reply.
What I now have is a class bisArray: ... template<typename T> class bisArray: public bisObject { typedef boost::variant < boost::multi_array_ref
, boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref , boost::multi_array_ref 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
_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.[...]
No, it's C (which doesn't use any of this -not properly at least). The whole this[...] business was not supposed to be there anyway I realised. The reason that I went to boost:: is that I was hoping to get one class for all data types (using T) and dimensionalities (using multi_array)
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.
Ah! The underscore names come from a library that I tried to imitate which has successfully incorporated some aspects of boost(it is called MIMAS). Have not reached the stage of 'nicifying' the code yet... I moved the storage thing to where you suggested (1 line up) and that does get rid of lots of errors. However what I am stuck with seems to be, in essence, still the same thing:
/home/amwink/programs/cpp/bis/src/bisniftiimage.cpp||In function ‘void bis::bisReadNifti(std::string)’:| /home/amwink/programs/cpp/bis/src/bisniftiimage.cpp|102|warning: unused variable ‘testimage’| /usr/include/boost/variant/variant.hpp||In constructor ‘boost::variant
::variant() [with T0_ = boost::multi_array_ref , T1 = boost::multi_array_ref , T2 = boost::multi_array_ref , T3 = boost::multi_array_ref , T4 = boost::multi_array_ref , T5 = boost::multi_array_ref , T6 = boost::multi_array_ref , T7 = boost::multi_array_ref , T8 = boost::multi_array_ref , T9 = boost::detail::variant::void_, T10 = boost::detail::variant::void_, T11 = boost::detail::variant::void_, T12 = boost::detail::variant::void_, T13 = boost::detail::variant::void_, T14 = boost::detail::variant::void_, T15 = boost::detail::variant::void_, T16 = boost::detail::variant::void_, T17 = boost::detail::variant::void_, T18 = boost::detail::variant::void_, T19 = boost::detail::variant::void_]’:| /home/amwink/programs/cpp/bis/src/bisarray.hpp|52|instantiated from ‘bis::bisArray<T>::bisArray(T*, size_t, std::vector ) [with T = unsigned char]’| /home/amwink/programs/cpp/bis/src/bisimage.hpp|33|instantiated from ‘bis::bisImage<T>::bisImage(T*, size_t, std::vector ) [with T = unsigned char]’| /home/amwink/programs/cpp/bis/src/bisniftiimage.cpp|126|instantiated from here| /usr/include/boost/variant/variant.hpp|1198|error: no matching function for call to ‘boost::multi_array_ref ::multi_array_ref()’| /usr/include/boost/multi_array/multi_array_ref.hpp|623|note: candidates are: boost::multi_array_ref ::multi_array_ref(T*, const typename boost::const_multi_array_ref ::storage_order_type&, const typename boost::const_multi_array_ref ::index*, const typename boost::const_multi_array_ref ::size_type*) [with T = unsigned char, long unsigned int NumDims = 1ul]| /usr/include/boost/multi_array/multi_array_ref.hpp|469|note: boost::multi_array_ref ::multi_array_ref(T*, const boost::detail::multi_array::extent_gen<NumDims>&, const boost::general_storage_order<NumDims>&) [with T = unsigned char, long unsigned int NumDims = 1ul]| /usr/include/boost/multi_array/multi_array_ref.hpp|463|note: boost::multi_array_ref ::multi_array_ref(T*, const boost::detail::multi_array::extent_gen<NumDims>&) [with T = unsigned char, long unsigned int NumDims = 1ul]| /usr/include/boost/multi_array/multi_array_ref.hpp|417|note: boost::multi_array_ref ::multi_array_ref(const boost::multi_array_ref &)| ||=== Build finished: 1 errors, 1 warnings ===|
So boost.variant now sugegsts that multi_array_ref() is called, a
constructor with no arguments! I don't use that, and I don't even
think it exists (because it produces a multi_array view of an
*existing* C-style array!
The only way I knew to initialise a bisArray was with using a switch
statement -proper C:
switch dims{
case 1: _bisarray=multi_array_ref