I have a std::list of "Ray"-objects, which I want to iterate over.
for (std::list<Ray>::const_iterator it = clRay.begin(), end = clRay.end(); it != end; ++it) { *it->setDir( m_v3Position - *it->getOrigin() ) } And the Ray objects have the methods setDir() and getOrigin():
const QVector3D &getOrigin() const { return m_v3Origin; } void setDir( const QVector3D &dir ) { m_v3Dir = dir; } The setdir() is no problem for the compiler, but I can't call getOrigin(). Because then I get the error:
src/AreaLight.cpp: In member function ‘virtual void AreaLight::shadowFeeler(std::__cxx11::list<Ray>&, double&, ColorType&) const’: src/AreaLight.cpp:18:17: error: no match for ‘operator*’ (operand type is ‘const QVector3D’) I think it is a const-problem, but I don't know how to fix it.
*it->setDir( m_v3Position - *it->getOrigin() )->it->setDir( m_v3Position - it->getOrigin() )for (auto& r : clRay) { r.setDir( m_v3Position - r.getOrigin() ); }it->setDir( m_v3Position - it->getOrigin() )I get the errorsrc/AreaLight.cpp:18:47: error: passing ‘const Ray’ as ‘this’ argument discards qualifiers [-fpermissive]iterator, you should not useconst_iteratorconst_iteratorand were callingsetDirwhich is not a constant function which does not make much sense.