/** @file $Id$ $Date$ $Author$ @copy © Marc Wäckerlin @license LGPL, see file COPYING $Log$ Revision 1.1 2004/10/07 09:31:30 marc new feature */ #ifndef __MRW__DEQUE__HPP__ #define __MRW__DEQUE__HPP__ #include #include #include /** @addtogroup StdExt */ //@{ /** @brief push a value to a deque @code std::deque test; test<<1<<2<<3<<4<<5<<6<<7<<8; @endcode @param l a deque of values @param o a value to be inserted into deque @c l @pre #include */ template std::deque& operator<<(std::deque& l, const T& o) throw(std::bad_exception) { l.push_back(o); return l; } /** @brief extract the first value of a deque @code std::deque test; test<<1<<2<<3<<4<<5<<6<<7<<8; int i1(0), i2(0), i3(0), i4(0); test>>i1>>i2>>i3>>i4; // now: i1==1 i2==2 i3==3 i4==4 test=={5, 6, 7, 8} @endcode @param l a deque of values @param o a value to be extracted from deque @c l @throw mrw::length_error, if deque was empty on entry @note when something is extracted from a deque, it is removed from the deque, that means after every shift the deque is shortened by the shifted element @pre #include */ template std::deque& operator>>(std::deque& l, T& o) throw(std::exception) { typename std::deque::iterator it(l.begin()); if (it==l.end()) throw mrw::length_error(std::string(__FILE__ ":")+__LINE__+ ": std::deque<>& operator>>(std::deque<>&, T&)," " deque is empty"); o = *it; l.erase(it); return l; } //@} #endif