/** @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__MULTIMAP__HPP__ #define __MRW__MULTIMAP__HPP__ #include #include #include /** @addtogroup StdExt */ //@{ /** @brief insert a value in a multimap @code std::multimap test; test< */ template std::multimap& operator<<(std::multimap& l, const std::pair& o) throw(std::bad_exception) { l.insert(o); return l; } /** @brief extract the first value of a multimap @code std::multimap test; test< i1, i2; test>>i1>>i2; // now: i1==(1, "one") i2==(2, "two") test=={} @endcode @param l a multimap of values @param o a value to be extracted from multimap @c l @throw mrw::length_error, if multimap was empty on entry @note when something is extracted from a multimap, it is removed from the multimap, that means after every shift the multimap is shortened by the shifted element @pre #include */ template std::multimap& operator>>(std::multimap& l, std::pair& o) throw(std::exception) { typename std::multimap::iterator it(l.begin()); if (it==l.end()) throw mrw::length_error(std::string(__FILE__ ":")+__LINE__+ ": std::multimap<>& operator>>(std::multimap<>&, T&)," " multimap is empty"); o = *it; l.erase(it); return l; } //@} #endif