Content deleted Content added
Thumperward (talk | contribs) archive oldest talk |
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB) |
||
Line 269:
Naturally, C preprocessor templates can be applied to C++ and make marvelous template<> free code that doesn't rot, as long as you avoid anything beyond the most lightweight use of native C++ templates in your own code... but even then you're asking for grief.
<
#ifndef CTL_POOL_H
#define CTL_POOL_H
Line 391:
}
#endif /* CTL_POOL_H */
</syntaxhighlight>
And here's how to use that thing... note that something repetitive like "SocketPool, &SockPool" can be wrapped in a macro as well, somewhat reducing the verbosity of the code (a useful trick for declaring repetitive C++ template parameters as well). Generally you want to wrap these things in a function, rather than use the naked allocator everywhere, because even small template code can tend to bloat up the application a bit. A problem many C++ implementations share.
Line 397:
Most of the other examples of templates I had handy were, uh, HUGE. They included code to pre-compile functions for variations of character type. Needless to say, this sort of code needs a fat set of unit tests written for it before it can be trusted to run in a larger application, but so do C++ templates.
<
struct Socket
{
Line 430:
}
</syntaxhighlight>
Line 442:
There is no explanation of this in this page, and what are some real world examples of how to use it - instead of the simple:
<
#define MACRO "someheader.h"
#include MACRO
</syntaxhighlight>
Is it possible to combine X-Macro capabilities with calculated includes? How would you do it? <small>—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/12.5.54.215|12.5.54.215]] ([[User talk:12.5.54.215|talk]]) 22:44, 13 July 2008 (UTC)</small><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
|