Sign in to follow this  

Viewing a C++ generated template code?

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there is any mean in which we can view the generated template of a given class using visual studio or any external tool or any other compiler (under Windows). for example we all know the vector template template<class _Ty, class _Ax> class vector : public _Vector_val<_Ty, _Ax> { ... } then i declare a variable like vector<int> vec1; the thing is i want to see a copy of the generated class were all the template parameters are replaced with the specified data types in our example the _Ty parameter gets replaced by the int data type I need this because it is too hard to know the real problem when writing a template and possibly miss something.

Share this post


Link to post
Share on other sites
A number of different compile errors tend to give you a great big long string with what parameters it has filled the template in with. It wont give you the whole code though.

Share this post


Link to post
Share on other sites
Perhaps this is what you are looking for - you can force the compiler to generate and compile all functions in the class template for a particular type - search for "explicit template instantiation", which can be helpful for finding compile errors lurking in your template code that don't show up until you first use particular functions.

As for getting an expanded version of the template source, I dont think you can easily do that.

Share this post


Link to post
Share on other sites

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this