|
||||
File indexing completed on 2025-01-18 09:54:39
0001 // ---------------------------------------------------------------------- 0002 // 0003 // ZMuseCount.icc - utility class for use in reference-counting 0004 // 0005 // 0006 // History: 0007 // 19-Sep-1997 WEB Design stolen, and code adapted, from pp 70-73 of 0008 // Koenig & Moo: "Ruminations on C++" (1996) 0009 // 23-Sep-1997 WEB Furnished overlooked body of copy constructor. 0010 // 0011 // ---------------------------------------------------------------------- 0012 0013 0014 ZMuseCount::ZMuseCount() 0015 : p( new int(1) ) 0016 { 0017 // DEBUG if ( p == 0 ) 0018 // DEBUG std::cerr << "ZMuseCount memory allocation failure!" << std::endl; 0019 } 0020 0021 0022 ZMuseCount::ZMuseCount( const ZMuseCount & u ) 0023 : p( u.p ) 0024 { 0025 ++*p; 0026 } 0027 0028 0029 ZMuseCount::~ZMuseCount() { 0030 if ( --*p == 0 ) 0031 delete p; 0032 } 0033 0034 0035 bool ZMuseCount::only() { 0036 return *p == 1; 0037 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |