The context
I recently found this question since I was searching a way to list all the available methods present in a class, so I started experimenting with the ptype command which made me post this question
Consider the following file
#include <array>
#include <vector>
#include <list>
int main() {
std::array <int, 1> a;
std::vector <int> v;
std::list <int> l;
return 0;
}
I can list all methods present in the array class by doing the following
g++ -g main.cpp && \
gdb -q -batch -ex 'break 10' -ex 'run' -ex 'ptype a' ./a.out
Breakpoint 1 at 0x1179: file main.cpp, line 10.
Breakpoint 1, main () at main.cpp:10
10 return 0;
type = struct std::array<int, 1> [with _Tp = int] {
std::__array_traits<_Tp, 1>::_Type _M_elems;
public:
void fill(reference);
void swap(std::array<_Tp, 1> &);
iterator begin(void);
iterator begin(void) const;
iterator end(void);
(... more methods ...)
However, this doesn't happen with the vector and list classes (see below).
Executing ptype on an instance of the vector class
g++ -g main.cpp && \
gdb -q -batch -ex 'break 10' -ex 'run' -ex 'ptype v' ./a.out
Breakpoint 1 at 0x1179: file main.cpp, line 10.
Breakpoint 1, main () at main.cpp:10
10 return 0;
type = std::vector<int>
Executing ptype on an instance of the list class
g++ -g main.cpp && \
gdb -q -batch -ex 'break 10' -ex 'run' -ex 'ptype l' ./a.out
Breakpoint 1 at 0x1179: file main.cpp, line 10.
Breakpoint 1, main () at main.cpp:10
10 return 0;
type = std::list<int>
The question
Why does ptype prints all the methods present in the array class but doesn't do the same with the vector and list classes?