i think you can't do that. reference type is not assignable or moveable. you may use pointer type but that's more trouble. you may use shared_ptr<> though. for c++0x, your concern doesn't not exist since map<> itself is movable. so value passing (of map<>) is as efficient as using explicit pointer.
【在 d****p 的大作中提到】 : Performance wise, better map< char, BIDMAP& > : otherwise modifying the outter map may trigger value passing of the inner : map a lot of times
A*e
34 楼
这厮太脑残,没啥好讨论的,看她出丑笑话一下就行了
【在 P*******i 的大作中提到】 : 那就讨论一下那个王芳妮?
L*1
35 楼
这个要去投。乡情线在哪
M*O
36 楼
z*o
37 楼
你给俺找一个?
【在 v******a 的大作中提到】 : 哦,原来你没小蜜啊,那情人节包子就省了
w*n
38 楼
haha. 恩
【在 h***e 的大作中提到】 : 大家都喜欢被god夸奖的感觉啊
d*p
39 楼
You are right: the mapped type cannot be reference since certain operations on map element may introduce reference of reference. So a pointer or wapper reference could be considered. Or use pointer container. Admire you are very much c++0x aware when talking any c++ topic :-) Let's wait for its arrival!
you so
【在 t****t 的大作中提到】 : i think you can't do that. reference type is not assignable or moveable. you : may use pointer type but that's more trouble. you may use shared_ptr<> : though. : for c++0x, your concern doesn't not exist since map<> itself is movable. so : value passing (of map<>) is as efficient as using explicit pointer.
you can use 0x in gcc 4.4+, or vc 10(?). not all of them, of course. but quite a lot is here.
operations
【在 d****p 的大作中提到】 : You are right: the mapped type cannot be reference since certain operations : on map element may introduce reference of reference. : So a pointer or wapper reference could be considered. Or use pointer : container. : Admire you are very much c++0x aware when talking any c++ topic :-) Let's : wait for its arrival! : : you : so
can't do it because references are unassignable. can use map.
【在 d****p 的大作中提到】 : Performance wise, better map< char, BIDMAP& > : otherwise modifying the outter map may trigger value passing of the inner : map a lot of times
something similar? to store in a custom list class that internally holds them in a std::map. The definition of this map within my list class is: instances of std::shared_ptr that I add to to m_cvars go out of scope as soon as the function I happen to be in when I add them finishes. I've tried multiple ways to do this, including: minVal, hasMax, maxVal));m_cvars[var_name] = cv;/* AND */m_cvars[var_name] = std::make_shared(ARGUMENTS FOR VARIABLE()); std::shared_ptrs with different ways of adding them to the map, such as: (var_name, cv));/* AND */m_cvars[var_name].reset(new Variable(ARGUMENTS)); function I am in, and try to access these variables from another part of my application, the shared_ptr exists in the map but it no longer points to a valid Variable. Does anyone know what I am doing wrong? I'm confused, u asked about creating a map of BIDMAP but now u use "Variable". is "Variable" same as BIDMAP? this should work under any circumstances: " typedef std::map< BookKey, depth_quote, BidRanker > BIDMAP; shared_ptr p( new BIDMAP( ... ) ); m_cvars.insert( std::make_pair( String, p ) ); "
【在 s****n 的大作中提到】 : Could u give me an example on how to use the shared_ptr<> ? Is this something similar?