* Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())?
@ 2022-11-20 19:45 Tan, Qiye
2022-11-20 20:01 ` Arsen Arsenović
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tan, Qiye @ 2022-11-20 19:45 UTC (permalink / raw)
To: libstdc++
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
Hi all,
I'm new in C++ who have an interest in the implementation of C++ STL.
Recently, I tried to implement my own vector template. However, when I
implemented my own iterator, I found that I had no idea how to
detect whether it is dereferencable. Therefore, I began to explore the
libstdc++, but I found that for some member functions, I can only find the
declaration but no definition. For example, the 'bool
__gnu_debug::_Safe_iterator_base::_M_singular( ) const', 'void
__gnu_debug::_Safe_iterator_base::_M_detach( )', etc. They are declared in
'libstdc++-v3/include/debug/safe_base.h'. I can guess that '_M_singular'
may just check if '_M_sequence' is NULL, but I still want to find their
definition. Can someone help me? Thank you so much.
Best,
Qiye Tan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())?
2022-11-20 19:45 Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())? Tan, Qiye
@ 2022-11-20 20:01 ` Arsen Arsenović
2022-11-20 20:16 ` François Dumont
2022-11-20 23:13 ` Jonathan Wakely
2 siblings, 0 replies; 4+ messages in thread
From: Arsen Arsenović @ 2022-11-20 20:01 UTC (permalink / raw)
To: Tan, Qiye; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]
Evening,
"Tan, Qiye via Libstdc++" <libstdc++@gcc.gnu.org> writes:
> I'm new in C++ who have an interest in the implementation of C++ STL.
> Recently, I tried to implement my own vector template. However, when I
> implemented my own iterator, I found that I had no idea how to
> detect whether it is dereferencable. Therefore, I began to explore the
> libstdc++, but I found that for some member functions, I can only find the
> declaration but no definition. For example, the 'bool
> __gnu_debug::_Safe_iterator_base::_M_singular( ) const', 'void
> __gnu_debug::_Safe_iterator_base::_M_detach( )', etc. They are declared in
> 'libstdc++-v3/include/debug/safe_base.h'. I can guess that '_M_singular'
> may just check if '_M_sequence' is NULL, but I still want to find their
> definition. Can someone help me? Thank you so much.
_M_singular() and _M_detach() are implemented in src/c++11/debug.cc. A
complete iterator implementation technically doesn't need either, these
are used for debugging purposes in libstdc++, see also
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/libstdc++/api/a05206.html
Do keep in mind that the __gnu_debug namespace is only used in case that
_GLIBCXX_DEBUG is set, see
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/libstdc++/manual/manual/debug_mode.html
Hope that helps, have a great night!
--
Arsen Arsenović
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())?
2022-11-20 19:45 Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())? Tan, Qiye
2022-11-20 20:01 ` Arsen Arsenović
@ 2022-11-20 20:16 ` François Dumont
2022-11-20 23:13 ` Jonathan Wakely
2 siblings, 0 replies; 4+ messages in thread
From: François Dumont @ 2022-11-20 20:16 UTC (permalink / raw)
To: libstdc++
On 20/11/22 20:45, Tan, Qiye via Libstdc++ wrote:
> Hi all,
>
> I'm new in C++ who have an interest in the implementation of C++ STL.
> Recently, I tried to implement my own vector template.
Good exercice !
> However, when I
> implemented my own iterator, I found that I had no idea how to
> detect whether it is dereferencable. Therefore, I began to explore the
> libstdc++, but I found that for some member functions, I can only find the
> declaration but no definition. For example, the 'bool
> __gnu_debug::_Safe_iterator_base::_M_singular( ) const', 'void
> __gnu_debug::_Safe_iterator_base::_M_detach( )', etc. They are declared in
> 'libstdc++-v3/include/debug/safe_base.h'. I can guess that '_M_singular'
> may just check if '_M_sequence' is NULL, but I still want to find their
> definition. Can someone help me? Thank you so much.
This is in the .so, all exports are done from the src folder.
For _GLIBCXX_DEBUG mode all implementation is in src/c++11/debug.cc.
François
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())?
2022-11-20 19:45 Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())? Tan, Qiye
2022-11-20 20:01 ` Arsen Arsenović
2022-11-20 20:16 ` François Dumont
@ 2022-11-20 23:13 ` Jonathan Wakely
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2022-11-20 23:13 UTC (permalink / raw)
To: Tan, Qiye; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
On Sun, 20 Nov 2022, 19:45 Tan, Qiye via Libstdc++, <libstdc++@gcc.gnu.org>
wrote:
> Hi all,
>
> I'm new in C++ who have an interest in the implementation of C++ STL.
> Recently, I tried to implement my own vector template. However, when I
> implemented my own iterator, I found that I had no idea how to
> detect whether it is dereferencable. Therefore, I began to explore the
> libstdc++, but I found that for some member functions, I can only find the
> declaration but no definition. For example, the 'bool
> __gnu_debug::_Safe_iterator_base::_M_singular( ) const', 'void
> __gnu_debug::_Safe_iterator_base::_M_detach( )', etc. They are declared in
> 'libstdc++-v3/include/debug/safe_base.h'. I can guess that '_M_singular'
> may just check if '_M_sequence' is NULL, but I still want to find their
> definition. Can someone help me? Thank you so much.
>
François and Arsen gave the answer already, but for future reference you
could clone the git repository and use 'git grep _M_singular' to find that.
> Best,
> Qiye Tan
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-20 23:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-20 19:45 Where is the definition of some member functions (ex. __gnu_debug::_Safe_iterator_base::_M_detach())? Tan, Qiye
2022-11-20 20:01 ` Arsen Arsenović
2022-11-20 20:16 ` François Dumont
2022-11-20 23:13 ` 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).