Discussion:
Edition of the example in the paragraph #3 of the section 27.4.2 Standard iterator tags
(too old to reply)
'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-26 14:34:35 UTC
Permalink
There is the following example

template inline void evolve(BidirectionalIterator first,
BidirectionalIterator last) {
evolve(first, last,
typename iterator_traits::iterator_category());
}


template void evolve(BidirectionalIterator first, BidirectionalIterator last
,
bidirectional_iterator_tag) {
// more generic, but less efficient algorithm
}


template void evolve(RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
// more efficient, but less generic algorithm
}

Should it be rewritten like

template void evolve(BidirectionalIterator first, BidirectionalIterator last
,
bidirectional_iterator_tag) {
// more generic, but less efficient algorithm
}


template void evolve(RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
// more efficient, but less generic algorithm
}

template inline void evolve(BidirectionalIterator first,
BidirectionalIterator last) {
evolve(first, last,
typename iterator_traits::iterator_category());
}


That is the first funcion should be the last.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...