* Re: libstdc++: std::iterator is deprecated since C++17
[not found] <CACWea6T=-jdu8TO2wG4=UAjhyBpp6K7k=vQOM2su9QTHHpSwHA@mail.gmail.com>
@ 2020-10-20 14:39 ` Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-10-20 14:39 UTC (permalink / raw)
To: korelkashri; +Cc: gcc-patches, libstdc++
Patches for libstdc++ need to be sent to both the gcc-patches list and
libstdc++ list, or they will be ignored.
Removing the std::iterator base classes is an ABI break, so not
acceptable.
std::iterator is deprecated, but that doesn't the library can't use
it. Even after it gets removed, we can continue to define it as a
non-standard extension, see the similar comments at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91260
If you want to add deprecated warnings to std::iterator that's fine,
but you'll need to also use #pragma to prevent uses within libstdc++
from giving any warnings.
One way to do that would be to introduce a new class template that
uses std::iterator and replaces all uses of std::iterator with that:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
typename _Pointer = _Tp*, typename _Reference = _Tp&>
struct __iterator
: iterator<_Category, _Tp, _Distance, _Pointer, _Reference>
{ };
#pragma GCC diagnostic pop
Ths will allow the library to use it without warnings, but user code
that refers to std::iterator will get warnings.
That would be a much simpler patch too.
We could also consider making it an alias template for C++11, to avoid
the cost of another class template instantiation:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
typename _Pointer = _Tp*, typename _Reference = _Tp&>
#if __cplusplus < 201103L
struct __iterator
: iterator<_Category, _Tp, _Distance, _Pointer, _Reference>
{ };
#else
using __iterator
= iterator<_Category, _Tp, _Distance, _Pointer, _Reference>;
#pragma GCC diagnostic pop
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-20 14:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CACWea6T=-jdu8TO2wG4=UAjhyBpp6K7k=vQOM2su9QTHHpSwHA@mail.gmail.com>
2020-10-20 14:39 ` libstdc++: std::iterator is deprecated since C++17 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).