Boost logo

Boost Users :

Subject: Re: [Boost-users] some problems about shared_ptr
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-09-10 11:38:40


AMDG

Samurai Deeper wrote:
> I am a newbie of C++ and I have some question about the shared_ptr
> I think the best way to explain it is with an example:
>
> /*******beginning of CValue.h*************/
> <snip>
> /****end*************/
>
> /*****Type.h***********/
>
> <snip>
>
> template<typename T, template <typename> class Value>
> struct Type
> {
> typedef boost::shared_ptr< Value<T> > pValue;
> };
>
>

What is the point of Type? It appears to be gratuitous complexity to me.

> /********end************/
>
>
> what if I want to make it as a composition class?
>

What do you mean by a composition class?

> by example
>
> /***************example**********/
> #include "Type.h"
> #include "CValue.h"
>
> template<typename T>
> class DIP //digital image processing
> {
> public:
> DIP();
> virtual ~DIP();
> shared_ptr < Type<T, filter> >createMediumFilter();
> };
>

What is filter here? Also, did you mean the
Type<T, filter>::pValue, aka shared_ptr<filter<T> >?

> <snip>
> /*****************end**************/
>
> I want to create the instance of mediumFilter like this in the main function
>
> int main()
> {
> Type<matrix<double>, Composition>::pValue C(new Composition<matrix<double>
>
>> );
>>
> Type<matrix<double>, CValue>::pValue D;
> D = C->createCValue();
>
> cout<<"system pause"<<endl;
> cin.get();
> }
>
> how could I fix the problems

I've read through this several times, and I'm afraid that
I don't understand what you're trying to do.

In Christ,
Steven Watanabe


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