Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ option to show what classes are created from templates

Tags:

c++

g++

Is there some g++ option which shows what classes are created from templates? For example there is template definition in original source code:

template <class T>
struct SomeStruct { T variable; };

SomeStruct<int> instance;

and I would like to see implementation of SomeStruct< int>.

like image 631
scdmb Avatar asked Oct 24 '22 16:10

scdmb


1 Answers

You can get that info with the -fdump-class-hierarchy flag. It'll list a lot more than you're asking for, but if search for lines that start with Class, you'll find what you're looking for.

EDIT: Here's some output from a program that includes iostream. You can see there are instantiations of char and wchar_t:

Class std::basic_ostream<char, std::char_traits<char> >
Class std::basic_ostream<char, std::char_traits<char> >::sentry
Class std::basic_ostream<wchar_t, std::char_traits<wchar_t> >
Class std::basic_ostream<wchar_t, std::char_traits<wchar_t> >::sentry
Class std::basic_istream<char, std::char_traits<char> >
Class std::basic_istream<wchar_t, std::char_traits<wchar_t> >
Class std::basic_istream<char, std::char_traits<char> >::sentry
Class std::basic_iostream<char, std::char_traits<char> >
Class std::basic_istream<wchar_t, std::char_traits<wchar_t> >::sentry
Class std::basic_iostream<wchar_t, std::char_traits<wchar_t> >
like image 64
eduffy Avatar answered Nov 15 '22 06:11

eduffy