Boost logo

Boost Users :

Subject: [Boost-users] [unordered_map] Trying to understand some errors
From: Craig Longman (craigl_at_[hidden])
Date: 2011-05-03 01:04:16


I'm using VS v9, just in case that matters in this case.

I'm :

     using namespace std;
     using namespace boost;

     unordered_map< string, uint32_t > xrf1;
     unordered_map< string, uint32_t >::const_iterator& iter =
xrf1.find( "hello" );

This is something I've used many times with the other containers (well,
std::map at least), but here I'm getting a conversion error. This is
resolved by either removing the reference marker, or removing the const
qualifier.

Can someone explain this please? I'd always thought that applying const
was easily done, and if so, then a reference should be sufficient,
right? Unless the const cast is marked as explicit somehow?

And as a side(ish) question, is there any real need to worry about have
an object versus reference to something like an iterator? I've always
tried to use references where I can, but I wonder if I should "just say
no" and use regular objects from now on?

Thanks,

-- 
Craig Longman
If it's not *signed* by me, then please don't assume it *is* from me.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net