1

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?

6
  • what if you remove the typedef and declare directly: std::vector<DebugVertex> mLineBuffer Commented Sep 23, 2010 at 10:59
  • Can you show some relevant diagnostic output? Commented Sep 23, 2010 at 10:59
  • Can you show us how you are trying to do reserve? Commented Sep 23, 2010 at 11:04
  • Here is the header/source file ampaste.net/m344006a7 - ampaste.net/m41c7fa65 Commented Sep 23, 2010 at 11:12
  • Did you try adding #include <vector>? Commented Sep 23, 2010 at 11:17

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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?

3 Comments

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: What did utArray's ptr method do? You may just be looking for &mLineBuffer[0], if my guess is correct that ptr returns a pointer to the internal array.
typedef T *Pointer; Pointer m_data; UT_INLINE Pointer ptr(void) { return m_data; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.