iwongu/sqlite3pp

C++17 deprecated usage of std::iterator as a base class

Closed this issue · 3 comments

Hi all,

While compiling with VisualStudio 2022 (and allowing C++20 features) I am getting the following warning:

headeronly_src\sqlite3pp.h(279,21): warning C4996: '<std::input_iterator_tag,sqlite3pp::query::rows,ptrdiff_t,sqlite3pp::query::rows *,sqlite3pp::query::rows &>': warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.

Would it be possible to follow the suggestion from the warning and not derive from std::iterator please (especially as it suggests that this never was an intention of the C++ Standard, even before C++17)?

Thank you,
Gorby

Looks like it was already discussed in "iterator fix #57", but I can't see that pull request completed in the source.

It's a little late, but fixed now.