By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Implicit user-conversion error

P: n/a
tim
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;

//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),p tr ) );
}
===
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?

May 4 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"ti*@DELETEMErobotcrazy.com" <ti*@robotcrazy.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.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),p tr ) );
: }
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
May 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.