Reputation: 862
I have:
class ThreadPool
{
public:
....
private:
struct TP_Thread: public Thread_t
{
....
};
std::vector<std::tr1::shared_ptr<TP_Thread> > m_threads;
.....
};
I wanna do something like:
typedef std::tr1::shared_ptr<TP_Thread> shpThread;
to shorten the writing in the class definitions. Problem is I either get pointer to incomplete type (because of forward declaration before the class and typedef the public section) or trying to access a private member of ThreadPool (in the case I'm trying to typedef it outside the class). How can I typedef this so I can use it freely during implementations?
Upvotes: 1
Views: 49
Reputation: 4501
Why not including your typedef in a public section of the class:
class ThreadPool
{
public:
....
private:
struct TP_Thread: public Thread_t
{
....
};
public:
typedef std::tr1::shared_ptr<TP_Thread> Shp;
...
then use ThreadPool::Shp
in your code.
Upvotes: 1