E
Exits Funnel
Hello,
I've got the following code:
//Begin foo.cpp
#include <set>
#include <vector>
class sq_t
{
int m_priority;
public:
void ClearPriority() { m_priority = 0; }
};
typedef std::set<sq_t> its_t;
typedef std::vector<sq_t> sq_seq_t;
class TDM_t
{
public:
typedef std::set<sq_t> its_t;
its_t m_IT;
};
int main( )
{
TDM_t tdm;
for (its_t::iterator i_it = tdm.m_IT.begin();
i_it != tdm.m_IT.end(); ++i_it )
{
(*i_it).ClearPriority(); //this is line 29
}
}
//End foo.cpp
The compiler (g++ 3.2.3) complains:
foo.cpp: In function `int main()':
foo.cpp:29: passing `const sq_priority_t' as `this' argument of `void
sq_priority_t::ClearPriority()' discards qualifiers
I think that I understand the problem which is related to this line:
typedef typename _Rep_type::const_iterator iterator;
in stl_set.h
I'm pretty sure I need to use const_cast to solve the problem but I
can't seem to get the syntax right. Help!
-exits
I've got the following code:
//Begin foo.cpp
#include <set>
#include <vector>
class sq_t
{
int m_priority;
public:
void ClearPriority() { m_priority = 0; }
};
typedef std::set<sq_t> its_t;
typedef std::vector<sq_t> sq_seq_t;
class TDM_t
{
public:
typedef std::set<sq_t> its_t;
its_t m_IT;
};
int main( )
{
TDM_t tdm;
for (its_t::iterator i_it = tdm.m_IT.begin();
i_it != tdm.m_IT.end(); ++i_it )
{
(*i_it).ClearPriority(); //this is line 29
}
}
//End foo.cpp
The compiler (g++ 3.2.3) complains:
foo.cpp: In function `int main()':
foo.cpp:29: passing `const sq_priority_t' as `this' argument of `void
sq_priority_t::ClearPriority()' discards qualifiers
I think that I understand the problem which is related to this line:
typedef typename _Rep_type::const_iterator iterator;
in stl_set.h
I'm pretty sure I need to use const_cast to solve the problem but I
can't seem to get the syntax right. Help!
-exits