Boost logo

Boost Users :

Subject: [Boost-users] Help with shared_ptr and template
From: Mario Chacon (the.masch_at_[hidden])
Date: 2009-01-27 22:24:48


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... :(

Thank you..
Mario..
Salu2...



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