Visual Studio 2012 intellisense and C++: Resolve template typenames to real class name

268 views Asked by At

I have the following code:

class BundyRead
{
};

class BundyWrite
{
};

template<class T>
class BarBaseT
{
public:
    typedef T BundyType;

    BarBaseT()
        : bundy_(BundyType())
    {
    }

    BundyType& getBundy()
    {
        return bundy_;
    }

private:
    BundyType bundy_;
};

class BarRead : public BarBaseT<BundyRead>
{
};

class BarWrite : public BarBaseT<BundyWrite>
{
};

template<class T>
class FooBaseT
{
public:
    FooBaseT()
        : bar_(T())
    {
    }

    T& getBar()
    {
        return bar_;
    }

    typename T::BundyType& getBundy()
    {
        return getBar().getBundy();
    }

protected:
    T bar_;
};

class FooRead : public FooBaseT<BarRead>
{
};

class FooWrite : public FooBaseT<BarWrite>
{
};

Instantiating concrete FooWrite and call both methods:

FooWrite fooWrite;
fooWrite.getBar();
fooWrite.getBundy();

If I want to see the return type of getBar() with intellisense I see it resolved the template typename to BarWrite, which is great. If I want to see the return type of getBundy() with intellisense it does not get resolved to BundyWrite as expected but

BarBaseT<BundyWrite>::BundyType&

I als noticed that if I use a typedef for T in FooBaseT and use that as the return type of getBar() instead of T it also does not get resolved to BarWrite. So I guess it has to do with the typedefs.

template<class T>
class FooBaseT
{
public:
    typedef typename T BarType;
...
BarType& getBar() {...}
...
};

I cant use something like typename T::T or something similar, right? Is there any chance to get the resolved concrete class types for intellisense? Otherwise its pretty hard to identify the correct return type for the user who uses my code.

0

There are 0 answers