Boost logo

Boost Users :

From: Doug Henry (brilligent_at_[hidden])
Date: 2005-06-18 08:38:11


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.

On 6/17/05, Jack Nguyen <bluekite2000_at_[hidden]> wrote:
>
> 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_at_[hidden]> 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_at_[hidden]> 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_at_[hidden]> 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_at_[hidden] > wrote:
> > > > > mpD=boost::shared_array<T>(new T[size]);
> > > > >
> > > > > On 6/16/05, Jack Nguyen <bluekite2000_at_[hidden]> 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_at_[hidden]
> > > > > >
> > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Cory Nelson
> > > > > http://www.int64.org
> > > > >
> > > > > _______________________________________________
> > > > > Boost-users mailing list
> > > > > Boost-users_at_[hidden]
> > > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > > >
> > > >
> > > > _______________________________________________
> > > > Boost-users mailing list
> > > > Boost-users_at_[hidden]
> > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > >
> > >
> > >
> > > _______________________________________________
> > > Boost-users mailing list
> > > Boost-users_at_[hidden]
> > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > >
> > >
> >
>
> _______________________________________________
> 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