Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ironfroggy

templates like macros?

This topic is 5237 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

Can templates do more than just create classes and functions for multiple data types? can they do more generalized replacements like macros, and are there any template conditionals like the preprocessor #ifdef?

Share this post


Link to post
Share on other sites
Advertisement
I''m not exactly sure if this is what you''re asking, but templates can do things like type switching, which can sort of act like preprocessor conditionals. However, the syntax for doing so is often less elegant. On the other hand, you get better type safety. This also comes with the caveat that there already different compiler/C++ features that can be used to replace preprocessor conditionals depending on the circumstances. For example, in most cases I prefer normal if statements on constants to #ifdef.

If you want a more specific explanation, try giving a specific example.

Share this post


Link to post
Share on other sites
Look up template metaprogramming. With a compiler that supports templates properly (*cough*VC6*cough*), they can be amazing.

edit: Two seconds late.. I must be getting old.

[edited by - psykr on January 24, 2004 1:52:57 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!