)]}'
{
  "commit": "1e10e9ea96a4141080a7cd7322babe6bcd7c42ba",
  "tree": "2bea0d0d703fc1a49159063662c6d29c1dfbc1d8",
  "parents": [
    "7a8821ff0e1badeaa284f6a6ff0b79b8e1fe5237"
  ],
  "author": {
    "name": "Simon Marchi",
    "email": "simon.marchi@efficios.com",
    "time": "Thu Aug 28 11:10:50 2025 -0400"
  },
  "committer": {
    "name": "Simon Marchi",
    "email": "simon.marchi@polymtl.ca",
    "time": "Fri Aug 29 16:08:27 2025 -0400"
  },
  "message": "gdbsupport: make filtered_iterator work with pointers\n\nIt\u0027s currently not possible to use filtered_iterator with a pointer as\nthe base iterator type.  This patch makes it possible.  The indended\nusage is:\n\n  Foo array[12];\n  Foo *begin \u003d array;\n  Foo *end \u003d array + ARRAY_SIZE (array);\n  filtered_iterator\u003cFoo *, FooFilter\u003e (begin, end);\n\nHere are the things that needed changing:\n\n - Give filtered_iterator a constructor where the caller provides\n   already constructed begin and end iterators.  filtered_iterator\n   currently assumes that default-constructing a BaseIterator will\n   produce a valid \"end\" iterator.  This is not the case if BaseIterator\n   is a pointer.  The caller needs to pass in the end of the array /\n   region to iterate on as the end.\n\n - Typedefs of member types like wouldn\u0027t work:\n\n     typedef typename BaseIterator::value_type value_type;\n\n   The compiler would complain that it\u0027s not possible to apply `::` to\n   type `BaseIterator` (aka `Foo *`).  Use std::iterator_traits to fix\n   it [1].\n\n - Similarly, the compiler would complain about the use of\n   `BaseIterator::operator*` in the return type of\n   `filtered_iterator::operator*`.  Fix this by using `decltype(auto)`\n   as the return type.  This lets the compiler deduce the return type\n   from the return statement.  Unlike `auto`, `decltype(auto)` perfectly\n   preserves the \"cvref-ness\" of the deduced return type.  If the return\n   expression yields a `Foo \u0026`, then the function will return a `Foo \u0026`\n   (which is what we want), whereas it would return a `Foo` if we used\n   just `auto`.\n\nImprove the filtered_iterator unit tests to run the same tests but with\npointers as iterators.  Because the filtered_iterator objects are\ninitialized differently in the two scenarios, I chose to copy the\nexisting code and adapt it.  It would probably be possible to add a\nlayer of abstraction to avoid code duplication, but it would end up more\ncomplicated and messy.  If we ever add a third scenario, we can revisit\nthat.\n\n[1] https://en.cppreference.com/w/cpp/iterator/iterator_traits.html\n\nChange-Id: Id962ffbcd960a705a82bc5eb4808b4fe118a2761\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "49c95cb2bf9414ade5eaa53d6d7d30176ed7ccf1",
      "old_mode": 33188,
      "old_path": "gdb/unittests/filtered_iterator-selftests.c",
      "new_id": "c04cae4963e0554b03ee093a1aa0398db13cf4ba",
      "new_mode": 33188,
      "new_path": "gdb/unittests/filtered_iterator-selftests.c"
    },
    {
      "type": "modify",
      "old_id": "e824d6115a8a5c900ebe0e6372ef0aae0ba1ad14",
      "old_mode": 33188,
      "old_path": "gdbsupport/filtered-iterator.h",
      "new_id": "4952582358b864e8a25cff55ba9df8a49e8bfbf9",
      "new_mode": 33188,
      "new_path": "gdbsupport/filtered-iterator.h"
    }
  ]
}
