Book Image

Boost C++ Application Development Cookbook

By : Antony Polukhin
Book Image

Boost C++ Application Development Cookbook

By: Antony Polukhin

Overview of this book

<p>Boost libraries are developed by professionals, tested on multiple platforms and processor architectures, and contain reliable solutions for a wide range of tasks. This Cookbook takes you on a journey of simplifying the process of application development and guides you through writing perfect applications fast.</p> <p>"Boost C++ Application Development Cookbook" provides you with a number of clear step-by-step recipes that will help you take advantage of the real power of Boost and C++, while giving you a good grounding in using it in any project.</p> <p>"Boost C++ Application Development Cookbook" looks at the Boost libraries, and breaks down the mystery and confusion about which library to use in which situation. It will take you through a number of clear, practical recipes that will help you to take advantage of the readily available solutions.</p> <p>Boost C++ Application Development Cookbook starts with teaching the basics of Boost libraries that are now mostly part of C++11 and leave no chance for memory leaks. Managing resources will become a piece of cake. We’ll see what kind of work can be done at compile time and what Boost containers can do. Do you think multithreading is a burden? Not with Boost. Think writing portable and fast servers is impossible? You’ll be surprised! Compilers and operating systems differ too much? Not with Boost. From manipulating images to graphs, directories, timers, files, strings – everyone will find an interesting topic.</p> <p>You will learn everything for the development of high quality fast and portable applications. Write a program once and then you can use it on Linux, Windows, MacOS, Android operating systems.</p>
Table of Contents (19 chapters)
Boost C++ Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using type "vector of types"


There are situations when it would be great to work with all the template parameters as if they were in a container. Imagine that we are writing something such as Boost.Variant:

#include <boost/mpl/aux_/na.hpp>

// boost::mpl::na == n.a. == not available
template <
    class T0 = boost::mpl::na, 
    class T1 = boost::mpl::na,
    class T2 = boost::mpl::na,
    class T3 = boost::mpl::na,
    class T4 = boost::mpl::na,
    class T5 = boost::mpl::na,
    class T6 = boost::mpl::na,
    class T7 = boost::mpl::na,
    class T8 = boost::mpl::na,
    class T9 = boost::mpl::na
>
struct variant;

And the preceding code is where all the following interesting tasks start to happen:

  • How can we remove constant and volatile qualifiers from all the types?

  • How can we remove duplicate types?

  • How can we get the sizes of all the types?

  • How can we get the maximum size of the input parameters?

All these tasks can be easily solved using Boost.MPL.

Getting ready

A basic knowledge...