In the previous articles I have used a very simplistic protocol. In real world situations this simple protocol is not sufficient. To provide a more robust connection between client and server a communications protocol is required so that we can vali…more
The last two articles examined the "C Socket" interface that is provided by OS. In this article I wrap this functionality in a very simple C++ class to provide guaranteed closing and apply a consistent exception strategy. The first step is to rewrite…more
Checking read/write success
write() command can fail in a couple of ways but can also succeed without reading/writing all the data, a common mistake is not to check the amount of data read/written from/to a stream. Interesting…more
Building a simple client/server application is the common first internet based applications developers attempt. These applications are built on top of the socket communication library, but socket programming in C++ is not obvious as there are no sta…more
So I never really considered why the resize of vector used a constant…more
So the C++ standard specifies a set of requirements for containers. Very few requirements are specified in terms of containers so adhering to these exactly is not required (unless you want to be considered for the standard). But they provide an insi…more
So now that we have used
std::is_nothrow_move_constructible we can also look at a couple of other types available in the template utility library.
Since we have to manually call the destructor on all objects in the contai…more
Because resizing a vector is expensive; the
std::vector class uses exponential growth to minimize the number of times that the vector is resized: a technique we replicate in this version. But every now and then you still need to resize the internal…more
In the previous article I went over basic allocation for a
Vector like class. In this article I want to put some detail around the copy assignment operator and resizing the underlying
Vector. Unlike the other methods previously discussed these m…more
A lot of new developers to C++ attempt to build a
Vector like container as a learning processes. Getting a simple version of this working for POD types (like int) is not that complicated. The next step in getting this working for arbitrary data ty…more
In this article we examine constructors that are often missed or overlooked. This article looks at the use cases for these constructors and explains why the added functionality provides a meaningful addition in relation to smart pointers.
On codereview.stackexchange.com in the C++ tag it seems that it is a write of passage to implement your own version of a smart pointer. A quick search brings up the following:
- 02/Sep/2011 - [shared_ptr imple…more
New Year/New Resolution
They say you can only get better at something by doing it.
I want to get better at writing articles about what I do so I better keep trying. Reading the articles I wrote last year (with the hindsight of a year) it seems my…more
So far we have demonstrated basic programs that just do a single task without making any decisions. Most (all but the most trivial) programming languages provide constructs for decision making (Conditional Branching).
C++ provides two forms of bran…more
Switching to OctoPress and Github
All C++ applications must have at least one function; this is called
main(). Additionally, you can have user defined functions that encapsulate individual tasks, thus allowing the code to be cleaner and easier to read. Therefore, this is…more
In most programming languages you have the concept of variables. These are simply named objects that hold a value (more formerly refereed to as state). By manipulating a variable you manipulate the state of the object that the variable…more
1: using namespace
Every new developer that comes to C++ always starts writing code like this:
#include <iostream> using namespace std;
It seems reasonable and every book on learning C++ out there perpetrates the sam…more
Setting up WordPress to display syntax highlighted code was a struggle due to different plugins that don’t all seem to work together, the different types of editor, etc. I don’t want to learn all about WordPress. I just want to write some simple art…more
This is the first article in the series
OK. Lets do this.
I keep trying to think about something big and interesting to write about. But that is just not working. All my time is spent trying to think of the blockbuster idea; which just gets in the w…more
We (SEOmoz.org) have been doing a lot of interviews for new engineers lately. I have been asked to help out trying to find the great new team members from the hordes of applicants (luckily we have a great team pre-screening app…more