It's possible weak_ptr could be used for that, but I have never used it
for that purpose. Have you checked out the boost
multi_array? It seems that container is very similar to the one
your creating.
Another related question: How do I refer to a subpart of an array
pointed to by shared_array. I tried
subptr=boost::shared_array<T>(ptr.get()+offset);
but this leaves me w/ dangling ptr problem :( Any suggestion???
On 6/17/05, Jack Nguyen <bluekite2000@gmail.com> wrote:
> Its a matrix constructor using pointer indirection. User can then do
> Matrix<double> M(3,4)//;
> and 2 arrays will be created, array1 of type *T, size 4 and array2 of
> type T, size 3*4. array1[0] points to array2[0], array1[1] points to
> array2[3] so on and so forth. I m having syntax trouble accomplishing
> the "array1[1] points to array2[3]" part!
>
> On 6/17/05, Doug Henry <brilligent@gmail.com> wrote:
> > It is really hard to tell what you are trying to do from this example.
> > Could you provide an example or description (not necessarily code) of what
> > your matrix structure should look like.
> >
> >
> >
> > On 6/17/05, Jack Nguyen < bluekite2000@gmail.com> wrote:
> > >
> > > I m trying to build a matrix and m having compile error w/ thei following
> > codes
> > > mpD=boost::shared_array<boost::shared_array<T>
> > >(new
> > > boost::shared_array<T>[cols]);
> > > mpD[0]=boost::shared_array<T>(new T[rows*cols]);
> > > for (int i=1; i<cols;i++)
> > > mpD[i]=mpD[0]+i*rows;
> > > Seems like there s no match for operator+
> > > Regards,
> > >
> > > On 6/16/05, Cory Nelson <phrosty@gmail.com > wrote:
> > > > mpD=boost::shared_array<T>(new T[size]);
> > > >
> > > > On 6/16/05, Jack Nguyen <bluekite2000@gmail.com> wrote:
> > > > > I currently have
> > > > >
> > > > > template <typename T>
> > > > > class Vector
> > > > > {
> > > > > private:
> > > > > int Size;
> > > > > boost::shared_array<T> mpD;
> > > > >
> > > > > void VecAlloc( int size)
> > > > > {
> > > > >
> > > > > boost::shared_array<T> mpD_temp(new T[size]);
> > > > > mpD=mpD_temp;
> > > > > }
> > > > >
> > > > > public:
> > > > > Vector()
> > > > > {
> > > > > }
> > > > > Vector(int size)
> > > > > :Size(size)
> > > > > {
> > > > > VecAlloc(size);
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > > My question is how do i get rid of boost::shared_array<T> mpD_temp(new
> > > > > T[size]); ???
> > > > >
> > > > > _______________________________________________
> > > > > Boost-users mailing list
> > > > > Boost-users@lists.boost.org
> > > > >
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > > >
> > > >
> > > >
> > > > --
> > > > Cory Nelson
> > > > http://www.int64.org
> > > >
> > > > _______________________________________________
> > > > Boost-users mailing list
> > > > Boost-users@lists.boost.org
> > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > >
> > >
> > > _______________________________________________
> > > Boost-users mailing list
> > > Boost-users@lists.boost.org
> > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users@lists.boost.org
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> >
>
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users