LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Strange compiling results with std::vector (https://www.linuxquestions.org/questions/programming-9/strange-compiling-results-with-std-vector-673908/)

The_Nerd 10-03-2008 02:29 AM

Strange compiling results with std::vector
 
I have a problem that suddenly popped up, and I am not quite sure what it is...
Forenote: I can not paste all of my code because my projects is rather large.

When I try to use a vector<T>::iterator, I get the following compile errors. As I said, this just suddenly started happening (and may have something to do with "Freetype", as it seams to have started after I included freetype in my project.

Code:

$make
g++ -DLINUX -DUSE_RENDERER_GL -g -O2 -Iinclude/ -IBox2D/Include -I/usr/include/freetype2 -Wreturn-type -c source/particle.cpp -o source/particle.o
source/particle.cpp: In member function ‘void Ner2D::Particle::CEmitter::Update()’:
source/particle.cpp:45: error: conversion from ‘std::_List_iterator<Ner2D::Particle::CParticle>’ to non-scalar type ‘__gnu_cxx::__normal_iterator<const Ner2D::Particle::CParticle*, std::vector<Ner2D::Particle::CParticle, std::allocator<Ner2D::Particle::CParticle> > >’ requested
source/particle.cpp:45: error: no match for ‘operator!=’ in ‘Itr != ((Ner2D::Particle::CEmitter*)this)->Ner2D::Particle::CEmitter::Particles. std::list<_Tp, _Alloc>::end [with _Tp = Ner2D::Particle::CParticle, _Alloc = std::allocator<Ner2D::Particle::CParticle>]()’
source/particle.cpp:47: error: passing ‘const Ner2D::Math::Types::CPoint’ as ‘this’ argument of ‘Ner2D::Math::Types::CPoint& Ner2D::Math::Types::CPoint::operator+=(const Ner2D::Math::Types::CVector&)’ discards qualifiers
make: *** [source/particle.o] Error 1

Here is the function:
Code:

/*--------------------------------------------------------------------*/
void CEmitter::Update()
{
        for (vector<CParticle>::iterator Itr = Particles.begin() ; Itr != Particles.end() ; Itr++)
        {
                (*Itr).Position += (*Itr).Velocity;
        }
}

And here is the header file:
Code:

#ifndef _PARTICLE_H_
#define _PARTICLE_H_
#include <vector>
#include "video.h"
#include "n2d_math.h"

using namespace std;

namespace Ner2D
{
        namespace Particle
        {
                class CParticle
                {
                        public:
                                Math::Types::CPoint Position;
                                Math::Types::CPoint Size;
                                Math::Types::CVector Velocity;
                                long lGroup;
                                Ner2D::Types::CAutoPointer<Ner2D::Material::CMaterial> Material;
                               
                                CParticle &operator=(const CParticle &Par);
                                CParticle();
                                CParticle(const CParticle &Par);
                };
               
                class CEmitter : public Renderer::CPrimitive, public NER2D_BASE_TYPE
                {
                        public:
                                NER2D_CLASS_HEADER(CEmitter);
                               
                                virtual void Draw();
                                virtual bool IsBlended() { return true; }
                                virtual ~CEmitter() {}
                                void Update();
                                CParticle *AddParticle(Ner2D::Types::CAutoPointer<Ner2D::Material::CMaterial> _Material = NULL);
                               
                                string Name;
                        protected:
                                list<CParticle> Particles;
                };
        }
}

#endif

I will greatly apprciate any help.

The_Nerd 10-03-2008 02:34 AM

Never mind... a moderator can delete this post... I was stupid enough to try to use a vector<T>::iterator on an std::list... I forgot I decided to change it to a list (:P)


All times are GMT -5. The time now is 02:20 AM.