a31e5cffa85f.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From a31e5cffa85f58b64a39fa7c4a1bd3bd9228b069 Mon Sep 17 00:00:00 2001
  2. From: Conrad Poelman <cpgithub@stellarscience.com>
  3. Date: Tue, 4 Aug 2020 17:20:40 -0400
  4. Subject: [PATCH] Remove deprecated inheritance from std::iterator (#97)
  5. std::iterator was deprecated in C++17 and removed in C++20. I replaced the inheritance with the 5 equivalent typedefs, even though they're not all used by ublas, for compatibility in case clients depend on them.
  6. ---
  7. .../boost/numeric/ublas/detail/iterator.hpp | 24 ++++++++++++++-----
  8. 1 file changed, 18 insertions(+), 6 deletions(-)
  9. diff --git a/include/boost/numeric/ublas/detail/iterator.hpp b/include/boost/numeric/ublas/detail/iterator.hpp
  10. index 1723a301c..7aebf2f9f 100644
  11. --- a/include/boost/numeric/ublas/detail/iterator.hpp
  12. +++ b/include/boost/numeric/ublas/detail/iterator.hpp
  13. @@ -107,8 +107,12 @@ namespace boost { namespace numeric { namespace ublas {
  14. * via the post increment operator.
  15. */
  16. template<class IC, class I, class T>
  17. - struct forward_iterator_base:
  18. - public std::iterator<IC, T> {
  19. + struct forward_iterator_base {
  20. + typedef IC iterator_category;
  21. + typedef T value_type;
  22. + typedef std::ptrdiff_t difference_type;
  23. + typedef T* pointer;
  24. + typedef T& reference;
  25. typedef I derived_iterator_type;
  26. typedef T derived_value_type;
  27. @@ -145,8 +149,12 @@ namespace boost { namespace numeric { namespace ublas {
  28. * via the post increment and post decrement operator.
  29. */
  30. template<class IC, class I, class T>
  31. - struct bidirectional_iterator_base:
  32. - public std::iterator<IC, T> {
  33. + struct bidirectional_iterator_base {
  34. + typedef IC iterator_category;
  35. + typedef T value_type;
  36. + typedef std::ptrdiff_t difference_type;
  37. + typedef T* pointer;
  38. + typedef T& reference;
  39. typedef I derived_iterator_type;
  40. typedef T derived_value_type;
  41. @@ -200,8 +208,12 @@ namespace boost { namespace numeric { namespace ublas {
  42. */
  43. template<class IC, class I, class T, class D = std::ptrdiff_t>
  44. // ISSUE the default for D seems rather dangerous as it can easily be (silently) incorrect
  45. - struct random_access_iterator_base:
  46. - public std::iterator<IC, T> {
  47. + struct random_access_iterator_base {
  48. + typedef IC iterator_category;
  49. + typedef T value_type;
  50. + typedef D difference_type;
  51. + typedef T* pointer;
  52. + typedef T& reference;
  53. typedef I derived_iterator_type;
  54. typedef T derived_value_type;
  55. typedef D derived_difference_type;