Game Engine Architecture Game Engine Architecture Spring 2017 Spring 2017
- 1. Modern C++ (11/14) for Game Engines
- 1. Modern C++ (11/14) for Game Engines
- 1. Modern C++ (11/14) for Game Engines
- 1. Modern C++ (11/14) for Game Engines
Juha Vihavainen Juha Vihavainen University of Helsinki University of Helsinki [Gregory, Ch. 3 [Gregory, Ch. 3 Fundamentals of SE for Games Fundamentals of SE for Games ] ] [Gregory, Ch. 3 [Gregory, Ch. 3 Fundamentals of SE for Games Fundamentals of SE for Games ] ] [Josuttis, Ch. 3 [Josuttis, Ch. 3 New Language Features New Language Features ] ] [ [Lakos Lakos, , Large Large-
- Scale C++ Software Design
Scale C++ Software Design ] ]
On the development of C++ On the development of C++
- 1998 ISO C++ Standard officially adopted. 776 p.
1998 ISO C++ Standard officially adopted. 776 p. RTTI, namespaces, RTTI, namespaces, export export, , bool bool, new cast syntax, many template , new cast syntax, many template extensions, exception specifications, etc., extensions, exception specifications, etc., std::string std::string, , STL STL
1979 => B.Stroustrup: Adding Classes to C. in Software Practice and Experience, Feb, 1983, pp. 139-161.
- 2003 ISO standard revision (bug fix release for C++98)
2003 ISO standard revision (bug fix release for C++98)
- 2003
2003 Library Library TR1: likely components, TR1: likely components, hash hash map, regex, smart pointers.. map, regex, smart pointers..
- 2006
2006 Performance Performance TR: A TR: A report on C++ performance issues
report on C++ performance issues
- 2009: Selected “C++0x” features became commonly available
2009: Selected “C++0x” features became commonly available
- 2011 ISO Standard ("C++0x" => "C++11/14"). 1353 p.
2011 ISO Standard ("C++0x" => "C++11/14"). 1353 p. auto auto, , static_assert static_assert, , constexpr constexpr, , uniform initialization uniform initialization, , move semantic, move semantic, auto auto, , static_assert static_assert, , constexpr constexpr, , uniform initialization uniform initialization, , move semantic, move semantic, lambda expressions lambda expressions, , threads, futures threads, futures, , locks locks, spec. of "machine model", , spec. of "machine model", template aliases, variadic templates, template aliases, variadic templates, extern extern ("do not instantiate here ("do not instantiate here")
")
- no "
no "concepts concepts" for generics (yet); removed " for generics (yet); removed export export, , auto_ptr auto_ptr, and old , and old version of exception specifications (that had proved to be bad ideas) version of exception specifications (that had proved to be bad ideas)
2.2.2017 2.2.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 2
A (simplified) family tree of C++ (Stroustup, 2014) A (simplified) family tree of C++ (Stroustup, 2014)
modelling experience with Simula (PhD thesis) => how to efficiently utilize .. other influences: Clu, Algol68, Ada: exceptions, generics,
- verloading..
how to efficiently utilize classes and inheritance
2.2.2017 2.2.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 3
On C++ type safety (refreshment) On C++ type safety (refreshment)
C++ is C++ is not not guaranteed to be statically or dynamically type safe guaranteed to be statically or dynamically type safe
- "a programming language designed for general and performance
"a programming language designed for general and performance critical systems programming with the ability to manipulate critical systems programming with the ability to manipulate hardware cannot be type safe" [Stroustrup] hardware cannot be type safe" [Stroustrup] hardware cannot be type safe" [Stroustrup] hardware cannot be type safe" [Stroustrup]
- the goal of preserved
the goal of preserved C compatibility compatibility assures such "unsafety", t assures such "unsafety", too
- Some problems (mostly features inherited from C)
Some problems (mostly features inherited from C)
- untagged unions (binary data reinterpreted as the current variant)
untagged unions (binary data reinterpreted as the current variant)
- explicit (and some implicit) unsafe type conversions (casts)
explicit (and some implicit) unsafe type conversions (casts)
- pointers and arrays without (guaranteed) checks
pointers and arrays without (guaranteed) checks
- pointers and arrays without (guaranteed) checks
pointers and arrays without (guaranteed) checks
- ability to deallocate a free store (heap) object while holding on to its
ability to deallocate a free store (heap) object while holding on to its "dangling" pointer (allowing post "dangling" pointer (allowing post-
- allocation access)
allocation access)
- deallocating an object not allocated, double deallocations..
deallocating an object not allocated, double deallocations..
2.2.2017 2.2.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 4