Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: templates -...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 9574 of 9830
Post > Topic >>

Re: templates - partial specialization

by Marcin Swiderski <sfider.best@[EMAIL PROTECTED] > May 7, 2008 at 06:31 PM

On 7 Maj, 18:58, Bharath <tiromarc...@[EMAIL PROTECTED]
> wrote:
> basically he is extending the Vector<void*> to Vector<T*>. Why is it
> so? In my example given above, I didn't derive from anything else. But
> I think I'm solving the purpose to define a specialization that is
> used for every my_vec of pointers and ONLY for my_vec of pointers.
> I couldn't understand the author's intention correctly. Can someone
> please explain ?

The solution shown in the example has the advantage of generating
less code then the naive solution. The code for handling vector of
pointers is generated only once (Vector<void*>) and then reused
with Vector<T*> thanks to ability to static_cast void* to T* for
every possible type T.

Cheers
Sfider

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 3 Posts in Topic:
templates - partial specialization
Bharath <tiromarch08@[  2008-05-07 10:58:39 
Re: templates - partial specialization
Marcin Swiderski <sfid  2008-05-07 18:31:54 
Re: templates - partial specialization
Carl Barron <cbarron41  2008-05-08 03:28:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:38:23 CDT 2008.