NAVI NING

The very beginning mind itself is the most accomplished mind of true enlightenment.

Smart Pointers without Reference Counting

auto_ptr, scoped_ptr and unique_ptr

Smart Pointers without Reference Counting #include <memory> C++ utilities library provides us three kinds of smart pointers without reference counting: auto_ptr, scoped_ptr and unique_ptr....

Smart Pointers

Powerful tools in memory management

Smart Pointers Pointers are the most powerful tools in C++, but programmers have to be responsible for the management of memory allocated on the heap. Any objects created with new has to be destro...

Move Semantics and Perfect Forwarding

Implement a vector container with Rvalue reference member functions

Move Semantics and Perfect Forwarding In the previous article, we learned member functions with Rvalue references as parameters. Member functions with Rvalue references are widely used in STL cont...

Member Functions with Rvalue References

Good approach to improve memory efficiency

Member Functions with Rvalue References In Chapter 5, we have implemented a class MyString that represents a string, in which its copy constructor and operator = is defined as MyString::MyString(...

Optimizing Objects in Functions

Three principles of using objects in functions

Optimizing Objects in Functions This article continues from the previous one. Here we defined a function getObject(), which takes a Test object as parameter, constructs an object tmp and returns i...

Behind the Object

What's happening when we are using objects.

Behind the Object In this chapter we are going to learn how to write efficient C++ code. Many performance issues are related to objects, so we must be clear about what is happening when we are usi...

Generic Algorithms, Binders and Lambda Expressions

Powerful algorithms to facilitate our work

Generic Algorithms, Binders and Lambda Expressions STL provides us powerful generic algorithms that can be used in containers. #include <algorithm> Generic algorithms accepts iterators as...

Function Objects

An important concept in advanced C++ programming

Function Objects A Function Object is simply any object that can be called as if it is a function. Remember in C, we can use function pointers like this: int sum(int a, int b) { return a + b;...

More about Iterators

iterator, const_iterator, reverse_iterator and const_reverse_iterator

More about Iterators As we have already known, iterators are useful to traverse elements in a STL container. However, there are also other types of iterators that are commonly used. iterator ite...

Associative Containers

set, map, unordered_set and unordered_map

Associative Containers There are two kinds of associative containers in STL: unordered associative containers and ordered associative containers. Unordered Associative Containers Unordered assoc...