feat(util/list): improve to_list function, it takes an optional tail

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-24 20:56:34 -08:00
parent 1a0f0c1609
commit afd10d62ca

View file

@ -169,8 +169,10 @@ template<typename T> unsigned length(list<T> const & l) {
}
/** \brief Return a list containing the elements in the subrange <tt>[begin, end)</tt>. */
template<typename It> list<typename std::iterator_traits<It>::value_type> to_list(It const & begin, It const & end) {
list<typename std::iterator_traits<It>::value_type> r;
template<typename It> list<typename std::iterator_traits<It>::value_type>
to_list(It const & begin, It const & end,
list<typename std::iterator_traits<It>::value_type> const & ls = list<typename std::iterator_traits<It>::value_type>()) {
list<typename std::iterator_traits<It>::value_type> r = ls;
auto it = end;
while (it != begin) {
--it;