Game Development Reference
In-Depth Information
Summary
This chapter has introduced you to some practical examples of template programming. You've seen
how to use templates to create classes with variables with types that are determined at compile
time. You've also seen how to create functions and methods that use templates.
Using standard templates like this allows you to write generic class implementations that can be
specialized with specific types at a later point in time. This is really useful to reduce the need to
copy and paste code when you might have been tempted to re-create a class to store a different
type of object.
This chapter also introduced the topic of template metaprogramming. This is a complex and useful
piece of C++ functionality but isn't used in a lot of code. It can be hard for many programmers to
understand and is seen as a relatively advanced topic. You saw in this chapter that C++ has some
built-in template metaprograms such as is_base_of and you also saw how you can create your own
template metaprograms. These programs are recursive in nature and can provide a good opportunity
to optimize your code by shifting calculations from runtime to compile time.
The next part of this topic covers more general game programming topics, as this part has drawn
the theoretical programming in C++ to a close. The next part covers design patterns, I/O streams,
memory management, concurrent programming, and cross-platform game development.
 
Search WWH ::




Custom Search