Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11076
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: calculate number of template instantiations |
| Date | 2011-10-25 09:32 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <j86dpp$jop$1@dont-email.me> (permalink) |
| References | <j86c4d$vmq$2@speranza.aioe.org> |
On 10/25/2011 9:04 AM, Ruslan Mullakhmetov wrote: > I got an interesting problem to play with templates. It's not abstract > and come from real life. I'm not sure wether it has solution within C++, > so I need advise and you opinions. > > In brief: I need to calculate number of template instantiation, > reasoning below. > > What I need. Assume I have some template Templ<T>. In the code I > instantiated it several times like Templ<A>, Templ<B>, ... Next I need > to get number of instantiation _prior_ to creating any of instances of > instantiated types. The code, I believe, clarify. Note, it's not compiling. > [...] A static data member in a template would be instantiated once per every template instantiation and initialized once. If that data member is of, say, 'int' type, you can initialize it by calling some function in which the counter would sit. Pass an argument to that function to indicate whether to increment the counter before returning it or just return what it has. It's not a problem, it sounds very much like a homework. V -- I do not respond to top-posted replies, please don't ask
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
calculate number of template instantiations Ruslan Mullakhmetov <tiabaldu@gmail.com> - 2011-10-25 17:04 +0400
Re: calculate number of template instantiations Victor Bazarov <v.bazarov@comcast.invalid> - 2011-10-25 09:32 -0400
Re: calculate number of template instantiations Noah Roberts <roberts.noah@gmail.com> - 2011-10-25 08:30 -0700
Re: calculate number of template instantiations Ruslan Mullakhmetov <tiabaldu@gmail.com> - 2011-10-25 20:05 +0400
Re: calculate number of template instantiations Arne Mertz <arnemertz@googlemail.com> - 2011-10-26 02:10 -0700
Re: calculate number of template instantiations Ruslan Mullakhmetov <tiabaldu@gmail.com> - 2011-10-25 19:42 +0400
Re: calculate number of template instantiations Noah Roberts <roberts.noah@gmail.com> - 2011-10-25 09:43 -0700
Re: calculate number of template instantiations Ruslan Mullakhmetov <tiabaldu@gmail.com> - 2011-10-25 20:46 +0400
csiph-web