473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C++ see template instantiations

152 100+
Hi!

Is there a way in either Visual Studio 2010 or g++ (any version) to see what classes it instantiates and their code? For example to see if i avoid code bloat when i explicitly instantiate a template for certain types.

Thanks!
Dec 17 '12 #1
3 1862
weaknessforcats
9,208 Expert Mod 8TB
I'm not sure what you are asking.

As you are probably aware, the compiler makes a copy of a template and substitutes the types you specify. So if 35 types can use the same logic you need write one function (the template) rather than coding the 35 implementations yourself.

Explicit specializations just tell the compiler not to use the template for the type you specify. This usually means the template logic can't be used for that type so you have written a function yourself for that type.

So where's the bloat?

Usually bloat refers to constructors, destructors and various member functions used to implement OOP. With today's large memory machines I don't hear about bloat much.

Please give me a little more to go on.
Dec 17 '12 #2
Tassos Souris
152 100+
See it as a general question about IDEs.. for example i make a simple main function where i use a std::vector<int> and maybe a std::list<std::string>.. where can i see that the compiler has generated those instantiations (not necessary see their code but e.g. symbols for their names, functions instantiated etc)... the only reason that it might be helpful to me is to see "in action" all the instantiation rules and specializations and stuff and stuff since i am now learning them
Dec 17 '12 #3
weaknessforcats
9,208 Expert Mod 8TB
Usually, I just use the debugger and step into the code. You will be able to step into the template where you can see the parameter type. Then you can step through the template.

Reading MSDN is more helpful than using the debugger.

Aceess to a good C++ textbook is better than using MSDN.
Dec 17 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Aleksandr Dubinskiy | last post by:
Hello folks, This question is a bit involved, so I am posting the code on the web, instead of cutting and pasting it on the email. http://www.cis.ohio-state.edu/~dubinski/Code/ I think the code...
2
by: Agent Mulder | last post by:
Hi group, I try to get a reference to a template. In the template, a virtual function is declared. Later in the program, I inherit from classes created by the template. So the template is the...
5
by: Gianni Mariani | last post by:
The spirit of this arguably pointless exercise, is that the numeric_limits<T> class could be replaced with a totally generic template of compile-time, template computed constants. The problem is...
9
by: Jon Wilson | last post by:
I have a class which needs to accumulate data. The way we get this data is by calling a member function which returns float on a number of different objects of different type (they are all the...
11
by: Matt | last post by:
I'm posting this question for one of my developers who's not quite as newsgroup-savvy. Any suggestions? The question follows, along with relevant source code. -Matt I have a templated...
5
by: PengYu.UT | last post by:
Hi, I know I can use "export" to compile library from the source code using templates. But I don't exactly know how to do it. Would you please give me some hint? Best wishes, Peng
3
by: sks | last post by:
Hello all Is the usage of extern keyword valid for telling the compiler to NOT instantiate a template and to link it from an another binary? For example: Suppose module A's binary contains a...
8
by: Imre | last post by:
Hi I'm looking for a way to make sure that whenever a new instance of a class template A is created, then an instance of class template B is also created, with the same template parameters. Of...
4
by: StephQ | last post by:
According to: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.4 , if my understanding is correct, in template<typename T> class Foo { friend void func (const Foo<T>& foo); }; ...
2
by: sunil | last post by:
reading http://docs.sun.com/source/819-3690/Program_Org.html#37468, I see there are two ways to instantiate templates: template definitions included, template definitions separate, does template...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.