fork download
  1. // 自己加的
  2. template <class _BidirectionalIter1, class _BidirectionalIter2,
  3. class _Distance, class other_iterator_tag>
  4. inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
  5. _BidirectionalIter1 __last,
  6. _BidirectionalIter2 __result,
  7. const other_iterator_tag &,
  8. _Distance*) {
  9. while (__first != __last)
  10. *--__result = *--__last;
  11. return __result;
  12. }
  13. // 原來的1
  14. template <class _BidirectionalIter1, class _BidirectionalIter2,
  15. class _Distance>
  16. inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
  17. _BidirectionalIter1 __last,
  18. _BidirectionalIter2 __result,
  19. const bidirectional_iterator_tag &,
  20. _Distance*) {
  21. while (__first != __last)
  22. *--__result = *--__last;
  23. return __result;
  24. }
  25. // 原來的2
  26. template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
  27. inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
  28. _RandomAccessIter __last,
  29. _BidirectionalIter __result,
  30. const random_access_iterator_tag &,
  31. _Distance*) {
  32. for (_Distance __n = __last - __first; __n > 0; --__n)
  33. *--__result = *--__last;
  34. return __result;
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:19:50: error: ‘bidirectional_iterator_tag’ does not name a type
                                            const bidirectional_iterator_tag &,
                                                  ^
prog.cpp:19:77: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
                                            const bidirectional_iterator_tag &,
                                                                             ^
prog.cpp:30:49: error: ‘random_access_iterator_tag’ does not name a type
                                           const random_access_iterator_tag &,
                                                 ^
prog.cpp:30:76: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
                                           const random_access_iterator_tag &,
                                                                            ^
prog.cpp:27:27: error: redefinition of ‘template<class _RandomAccessIter, class _BidirectionalIter, class _Distance> _BidirectionalIter __copy_backward(_RandomAccessIter, _RandomAccessIter, _BidirectionalIter, const int&, _Distance*)’
 inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
                           ^
prog.cpp:16:28: error: ‘template<class _BidirectionalIter1, class _BidirectionalIter2, class _Distance> _BidirectionalIter2 __copy_backward(_BidirectionalIter1, _BidirectionalIter1, _BidirectionalIter2, const int&, _Distance*)’ previously declared here
 inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
                            ^
stdout
Standard output is empty