my initial idea does not work - full copy on shift in, reference on shift out; refs #6
This commit is contained in:
@@ -49,21 +49,12 @@
|
||||
@param o a value to be inserted into vector @c l
|
||||
@pre \#include <mrw/vector.hxx>
|
||||
*/
|
||||
#ifdef MRW__OLD_PRE11_COMPILER
|
||||
template <typename T, typename A>
|
||||
std::vector<T, A> operator<<(std::vector<T, A> l, const T& o)
|
||||
throw(std::bad_exception) {
|
||||
l.push_back(o);
|
||||
return l;
|
||||
}
|
||||
#else
|
||||
template <typename T, typename A>
|
||||
std::vector<T, A>&& operator<<(std::vector<T, A>&& l, const T& o)
|
||||
throw(std::bad_exception) {
|
||||
l.push_back(o);
|
||||
return l;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @brief extract the first value of a vector
|
||||
|
||||
@@ -83,9 +74,8 @@ template <typename T, typename A>
|
||||
shortened by the shifted element
|
||||
@pre \#include <mrw/vector.hxx>
|
||||
*/
|
||||
#ifdef MRW__OLD_PRE11_COMPILER
|
||||
template <typename T, typename A>
|
||||
std::vector<T, A> operator>>(std::vector<T, A> l, T& o)
|
||||
std::vector<T, A>& operator>>(std::vector<T, A>& l, T& o)
|
||||
throw(std::exception) {
|
||||
typename std::vector<T, A>::iterator it(l.begin());
|
||||
if (it==l.end())
|
||||
@@ -96,20 +86,6 @@ std::vector<T, A> operator>>(std::vector<T, A> l, T& o)
|
||||
l.erase(it);
|
||||
return l;
|
||||
}
|
||||
#else
|
||||
template <typename T, typename A>
|
||||
std::vector<T, A>&& operator>>(std::vector<T, A>&& l, T& o)
|
||||
throw(std::exception) {
|
||||
typename std::vector<T, A>::iterator it(l.begin());
|
||||
if (it==l.end())
|
||||
throw mrw::length_error(std::string(__FILE__ ":")+__LINE__+
|
||||
": std::vector<>& operator>>(std::vector<>&, T&),"
|
||||
" vector is empty");
|
||||
o = *it;
|
||||
l.erase(it);
|
||||
return l;
|
||||
}
|
||||
#endif
|
||||
//@}
|
||||
//@}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user