Boost logo

Boost Users :

From: Antonio Piccolboni (piccolbo_at_[hidden])
Date: 2006-03-05 20:28:59


Use origin() if you you want to go straight to the element level, or
alternatively define a one-dimensional view of your liking and use begin()
(not clear from your code what you are trying to achieve,
but iVoxel = oVolume.origin() should do it). I hope this helps

Antonio

On 3/5/06, Christian Henning <chhenning_at_[hidden]> wrote:
>
> Hi there, I'm a little confused by the documentation of the
> multi_array lib. The begin() is supposed to return an iterator, but
> dereferencing doesn't resolve into the value type. This makes it a
> little complicated to use multi_arrays with standard algorithms.
> Please consider the following code snippet which wont compile on VC
> 7.1.
>
> class tVoxel
> {
> public:
>
> typedef short tValue;
>
> tVoxel(): _oValue( 0 ) {}
> tVoxel(tValue oValue): _oValue( oValue ) {}
>
> void set( const tValue& oValue ) { _oValue = oValue; }
>
> tValue& get() { return _oValue; }
> const tValue& get() const { return _oValue; }
>
> private:
>
> tValue _oValue;
> };
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> typedef boost::multi_array<tVoxel, 3> tVolume;
>
> tVolume oVolume( boost::extents[3][3][3] );
>
> tVolume::const_iterator iVoxel = oVolume.begin();
> tVolume::const_iterator iVoxelEnd = oVolume.end();
>
> const tVoxel& oVoxel = iVoxel->get();
>
> return 0;
> }
>
> The error message goes like:
>
> error C2039: 'get' : is not a member of
> 'boost::detail::multi_array::const_sub_array<T,NumDims>'
> with
> [
> T=tVoxel,
> NumDims=2
> ]
>
>
> Do I miss something important, here?
>
> Thanks for your help,
> Christian
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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