Re: Implicit user-conversion error
"tim@DELETEMErobotcrazy.com" <tim@robotcrazy.com> wrote in message
news:1146730221.934758.33920@j73g2000cwa.googlegroups.com...
: Our coding standard checker is reporting an implicit user conversion
: for the following:
:
: ===
: std::vector<PepLines>* ptr = NULL;
: std::map<peppage::ePepPage, std::vector<PepLines>*>::iterator mapiter =
: NULL;
This is simply illegal: an iterator cannot legally be initialized
with a pointer or a NULL.
You need to either leave it default-initialized (but you then cannot
use the iterator until a value is assigned to it), or you must
set it to someCollection.end() .
Keep in mind that behavior is undefined if you compare iterators
that do not point into the same collection instance.
: //create the containers to put the PepLines into, one vector for each
: pep page
: //then pass the pointer into the container. The destruction of these
: objects
: //will be handled in the CPepPageGraphics destructor.
: for(int
:
looper=peppage::PEP_PAGE_NULL;looper<peppage::PEP_PAGE_END_PAGE;looper++)
: {
: ptr = new std::vector<PepLines>;
: m_PageGraphicsCollection.insert(
: make_pair(static_cast<peppage::ePepPage>(looper),ptr ) );
: }
This incomplete code extract is confusingly incomplete.
How is mPageGraphicsCollection declared ?
: ===
: m_PageGraphicsCollection is defined thus:
:
: std::map<peppage::ePepPage, std::vector<PepLines>*>
: m_PageGraphicsCollection;
: ===
:
: The error is noted on the last line of code,
: m_PageGraphicsCollection.insert...
:
: I thought I'd matched up my types correctly, any ideas?
You really should use typedefs, this will clarify your
code and help avoid errors.
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form