--- linuxsampler/trunk/src/common/Pool.h 2005/03/17 00:14:41 471 +++ linuxsampler/trunk/src/common/Pool.h 2005/03/17 19:54:51 472 @@ -35,9 +35,12 @@ #if USE_EXCEPTIONS # include # include -const std::string __err_msg_iterator_invalidated = "Pool/RTList iterator invalidated"; #endif // USE_EXCEPTIONS +#if DEVMODE +const std::string __err_msg_iterator_invalidated = "Pool/RTList iterator invalidated"; +#endif + // just symbol prototyping template class Pool; template class RTList; @@ -79,12 +82,15 @@ /// prefix increment op. inline _Iterator& operator++() { - #if DEVMODE - #if USE_EXCEPTIONS - if (!isValid()) throw std::runtime_error(__err_msg_iterator_invalidated); - #else - if (!isValid()) return *(_Iterator*)NULL; // force segfault if iterator became invalidated - #endif // USE_EXCEPTIONS + #if DEVMODE + if (!isValid()) { + #if USE_EXCEPTIONS + throw std::runtime_error(__err_msg_iterator_invalidated); + #else + std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; + return *(_Iterator*)NULL; // force segfault if iterator became invalidated + #endif // USE_EXCEPTIONS + } #endif // DEVMODE fallback = current; current = current->next; @@ -94,18 +100,21 @@ /// postfix increment op. inline _Iterator operator++(int) { _Iterator preval = *this; - ++*this; + ++*this; // use prefix operator implementation return preval; } /// prefix decrement op. inline _Iterator& operator--() { - #if DEVMODE - #if USE_EXCEPTIONS - if (!isValid()) throw std::runtime_error(__err_msg_iterator_invalidated); - #else - if (!isValid()) return *(_Iterator*)NULL; // force segfault if iterator became invalidated - #endif // USE_EXCEPTIONS + #if DEVMODE + if (!isValid()) { + #if USE_EXCEPTIONS + throw std::runtime_error(__err_msg_iterator_invalidated); + #else + std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; + return *(_Iterator*)NULL; // force segfault if iterator became invalidated + #endif // USE_EXCEPTIONS + } #endif // DEVMODE fallback = current; current = current->prev; @@ -115,34 +124,37 @@ /// postfix decrement op. inline _Iterator operator--(int) { _Iterator preval = *this; - --*this; + --*this; // use prefix operator implementation return preval; } inline T1& operator*() { - #if DEVMODE - #if USE_EXCEPTIONS - if (isValid()) return *current->data; - else throw std::runtime_error(__err_msg_iterator_invalidated); - #else - return *(isValid() ? current->data : (T1*)NULL); // force segfault if iterator became invalidated - #endif // USE_EXCEPTIONS - #else - return *current->data; + #if DEVMODE + if (!isValid()) { // if iterator became invalidated + #if USE_EXCEPTIONS + throw std::runtime_error(__err_msg_iterator_invalidated); + #else + std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; + return *((T1*)NULL); // force segfault if iterator became invalidated + #endif // USE_EXCEPTIONS + } #endif // DEVMODE + return *current->data; + } inline T1* operator->() { #if DEVMODE - #if USE_EXCEPTIONS - if (isValid()) return current->data; - else throw std::runtime_error(__err_msg_iterator_invalidated); - #else - return isValid() ? current->data : (T1*)NULL; // force segfault if iterator became invalidated - #endif // USE_EXCEPTIONS - #else - return current->data; + if (!isValid()) { // if iterator became invalidated + #if USE_EXCEPTIONS + throw std::runtime_error(__err_msg_iterator_invalidated); + #else + std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; + return (T1*)NULL; // force segfault if iterator became invalidated + #endif // USE_EXCEPTIONS + } #endif // DEVMODE + return current->data; } inline bool operator==(const _Iterator other) {