Boost logo

Boost Users :

Subject: Re: [Boost-users] Help with shared_ptr and template
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-01-27 22:31:34


On Tue, Jan 27, 2009 at 7:24 PM, Mario Chacon <the.masch_at_[hidden]> wrote:
> Hello:
> I have this problem and I do not how to fix it, I know I cannot write
> template typedefs, its a limitiation of the C++ syntax, right? or I'm wrong?
> I saw that the best way is to wrap your typedefs in a struct, which can be
> templated, but I'm still stack with problems. The best way to explain it's
> with an example:
>
> #include <cstdlib>
> #include <iostream>
> #include <boost/shared_ptr.hpp>
>
> template< typename tvalue >
> class CValue
> {
> public:
> CValue( tvalue value ) : value_(value) {};
>
> private:
> tvalue value_;
> };
>
>
> template< typename tvalue >
> struct Type{
> typedef boost::shared_ptr< CValue< tvalue > > pValue;
> };
>
> int main(int argc, char *argv[])
> {
> Type<bool>::pValue a;
>
> return EXIT_SUCCESS;
> }
>
> How can I create a shared_ptr for the template class "CVALUE"??
> Please I do not know what else I can prove... :(

Your code seems to compile fine, what's the problem?

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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