c++ - "no operator "!=" matches these operands" for Iterator comparison after migration to VS2015 -
i upgrading vc++6 project vs2015. have if
statement checking iterator against being null
(actually 0). code building in vc++6 , vs2003 without error in vs2015 throws error. here code:
here type definitions:
#define null 0 typedef std::list <bsctrk *> bsctl; typedef bsctl::iterator bsctli; // data type of iterator trunk linked list typedef struct { int tsnum; bsctli tli; // iterator of trunk reset } tnkreset; extern tnkreset gtnkreset;
here piece code throwing error in vs2015:
if (gtnkreset.tli != null) resetradtnk (gtnkreset.tli);
error:
severity code description project file line column suppression state detail description error (active) no operator "!=" matches these operands bscc operand types are: bsctli != int
i have tried nullptr didn't help.what problem here?
you should never compare iterators else other iterators same container. proper way initialize "empty" iterator give value of end()
container.
std::list<int> list; auto itor = list.end(); // ... if (itor == list.end()) // itor not pointing anywhere interesting
as why you're having error 2015, not 2003 or (gasp!) 6.0, implementation of iterators in visual c++'s standard library has changed on time. might have had constructor taking pointer or weird operator==
, knows.
Comments
Post a Comment