|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-11 07:15:50
David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> template<class T> void write( std::ostream & os, boost::shared_ptr<T>
>> const & pt )
>> {
>> if( pt )
>> {
>> int pid = wpmap[ pt ];
>>
>> if( pid != 0 )
>> {
>> write( os, pid );
>> }
>> else
>> {
>> pid = wpmap.size();
>
> I could be wrong, but don't you need to add 1 here? wpmap starts out
> empty, after all.
It's a complete and working program, just run it. ;-) wpmap[pt] has already
added the element. map::find-based code needs +1.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk