This section lists some of the articles published at this site. These are grouped by topic and include select techniques for Modern C++ Programming, Realtime 3D Rendering, iOS Development and more. You can also browse the complete C++ archive to access all the articles.
Modern C++ Programming (C++11)
The new C++ standard is here and compiler support is more widespread than I had originally expected! In this post I explore some of the new language goodies including new iterators, lambda expressions and new auto semantics.
Move semantics are a new mechanism built into C++ that allow us to “move” data from one object to another. They help avoid full object copies that, today, could occur under different scenarios. Move semantics let us write special functions that can “steal” a source object’s inner data and assign it to a new object. It could help you avoid an expensive copy operation when you know the source object is not going to be used anymore.
Move semantics are a new mechanism built into C++ that allow us to “move” data from one object to another. They help avoid full object copies that, today, could occur under different scenarios. In this article I continue where I left off last week and show an updated version of the code that implements move semantics.
Inspired by the concept of Variadic Functions in C, the idea behind Variadic Templates is to allow a template to be instanciated with any number of arguments. In this article I’ll cover the new syntax and present a simple example that declares a function that uses a Variadic Template that prints the number of arguments it was intantiated with.
Inspired by the concept of Variadic Functions in C, the idea behind Variadic Templates is to allow a template to be instanciated with any number of arguments. In this article we build on those concepts to implement a printf-like function with the properties of being typesafe, don’t requiring parsing formatting characters and supporting non-POD data types.
With the release of the C++11 standard, C++ finally obtained its own enum type declarations. Dubbed “enum classes”, these new enums type define a namespace for the discrete values they contain. This sets them apart from classic C-style enums, which define their values in the enclosing scope. Enum classes can also be forward declared, helping improve compilation times by reducing transitive header inclusion.
Programming for iOS and the Mac
Objective-C is a superset of the C programming language that adds object-oriented constructs. Unlike C++, which was influenced by Simula, Objective-C was influenced by Smalltalk, something we can definitely see in its braces syntax.
Objective-C Blocks are easy to use constructs that enable defining functions “on the fly” when programming in Objective-C and are very similar to Python’s and C++11’s lambda expressions. The syntax might look a little weird at first, but it is not that different from working with function pointers in C, only better!
In this post, we delve into some advanced properties of blocks in the Objective-C language: capturing the enclosing scope, modifying captured variables and caveats related to memory allocation for blocks.
While Objective-C is a superset of C, the way its designers decided to implement the Object model was dynamic. This provides a strong contrast with C++, which, although a superset of C as well, is a static-typed language. In this post I will show how you can use the Objective-C runtime to dynamically add a method to an Objective-C class at runtime.
Although the compiler most commonly used on Mac OS X is the GCC compiler, the version supplied by Apple has a handful of modifications which are specific for OS X. In particular, the -shared compiler flag, used to create Shared Objects under GNU/Linux based systems, has no effect…
One of the main reasons C is so different from C++ is that C does not include classes and thus would be -in principle- not object oriented. The fact that the language does not include provisions for creating classes does not preclude adopting some sort of object-oriented programming style, however. In this post I’m going to introduce Opaque-Type Oriented Programming, a technique that allows our C programs to be structured as if they were populated with objects.
C++, as many other Object-Oriented languagues, provides many facilities for us to implement our Object Oriented Designs. In this post I talk about a feature which is not frequently discussed, but must be taken into account when implementing a class hierarchy that leverages polymorphism as part of its design.
Static libraries provide a mechanism by which we can “pack” object code into reusable libraries. In this article I’m going to focus on creating static libraries of C (and C++) objects and functions.
In my University, the programming language used for teaching how to program is Java. I was discussing with a colleague the disadvantages I saw in using it as a language for teaching programming basics and why, in my mind, it didn’t stack up against teaching a language such as plain C. The following story aims to reproduce the high points in the conversation.
If you have a desktop computer and a laptop chances are that, in the long run, you end up spending more time working on your laptop than on your desktop. If repurposing your old desktop into a fully fledged server seems like too much of a commitment (either because you do not have the time to set it up or do not want to give up your desktop), you can still configure it as to offer services to other computers on your network without having to go for a server operating system…