tags:

views:

46

answers:

2

I made a post about this yesterday, but it is a fairly different question. Not sure if I should make a new question or just reply to the old one but here goes.

Basically I am setting up my vector array of structs as follows..

class Debugger : public Ogre::SimpleRenderable
{
    struct DebugVertex
    {
        Ogre::Vector3 v;
        unsigned int color;
    };

    typedef std::vector<DebugVertex> Buffer;

protected:

    Buffer              mLineBuffer;

The problem is occuring in the code for example...

mLineBuffer.reserve(128); reports it is not a member of Debugger::DebugVertex. This holds true with all vector operations such as reserve, empty, ptr, size, etc. They all exist but it is looking for them in the struct. How am I supposed to access these?

A: 

What's the exact compiler error? My guess is that DebugVertex does not conform to the interface required for inclusion in STL containers like std::vector, possibly because Ogre::Vector3 needs work.

Can you include the declaration for Ogre::Vector3?

Steve Townsend
Well for some reason I just recompiled without changing anything (to bring back up the errors) and it compiled fine minus a couple of simple errors. I don't know what caused them before, but for some reason they are gone. I am wondering though, utArray (what I am replacing with vector) used mLineBuffer.ptr(); I can't find an equivalent function in vector, is there not one?
Brett Powell
Ogre::Vector3 code is available online, see http://ogre3d.org
Klaim
Roger Pate
typedef T *Pointer;Pointer m_data;UT_INLINE Pointer ptr(void) { return m_data; }
Brett Powell
+1  A: 

Your typedef using a private struct, any code outside the Debugger class trying to use it will not compile.

std::vector is not part of your class...

Either make std::vector<DebugVertex> a friend class (didn't test, have to check) or simply make your structure public.

Klaim