-
Jan Trávníček authoredJan Trávníček authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
list.hpp 934 B
/*
* list.hpp
*
* Created on: Apr 1, 2013
* Author: Jan Travnicek
*/
#ifndef __LIST_HPP_
#define __LIST_HPP_
namespace std {
template< class T, class ... Ts >
std::ostream& operator<<(std::ostream& out, const std::list<T, Ts ... >& list) {
out << "[";
bool first = true;
for(const T& item : list) {
if(!first) out << ", ";
first = false;
out << item;
}
out << "]";
return out;
}
template<class T, class ... Ts >
struct compare<list<T, Ts ... >> {
int operator()(const list<T, Ts ... >& first, const list<T, Ts ... >& second) const {
if(first.size() < second.size()) return -1;
if(first.size() > second.size()) return 1;
compare<typename std::decay < T >::type > comp;
for(auto iterF = first.begin(), iterS = second.begin(); iterF != first.end(); ++iterF, ++iterS) {
int res = comp(*iterF, *iterS);
if(res != 0) return res;
}
return 0;
}
};
} /* namespace std */
#endif /* __LIST_HPP_ */