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:
parent
1a0f0c1609
commit
afd10d62ca
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue