Learning Boost C++ Libraries
eBook - ePub

Learning Boost C++ Libraries

Arindam Mukherjee

Share book
  1. 558 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Boost C++ Libraries

Arindam Mukherjee

Book details
Book preview
Table of contents
Citations

About This Book

About This Book

  • Provide support to your programming tasks and data structures with Boost libraries
  • Write efficient and maintainable code to enhance the performance of your applications
  • A step by step guide, filled with real-world examples to give you the perfect start with Boost libraries

Who This Book Is For

If you are a C++ programmer who has never used Boost libraries before, this book will get you up-to-speed with using them. Whether you are developing new C++ software or maintaining existing code written using Boost libraries, this hands-on introduction will help you decide on the right library and techniques to solve your practical programming problems.

What You Will Learn

  • Write efficient and maintainable code using expressive interfaces from Boost libraries
  • Leverage a variety of flexible, practical, and highly efficient containers and algorithms beyond STL
  • Solve common programming problems by applying a wide array of utility libraries
  • Design and write portable multithreaded code that is easy to read and maintain
  • Craft highly scalable and efficient TCP and UDP servers
  • Build and deploy Boost libraries across a variety of popular platforms
  • Use C++11 functionality and emulate C++11 language features in C++03 code

In Detail

Filled with dozens of working code examples that illustrate the use of over 40 popular Boost libraries, this book takes you on a tour of Boost, helping you to independently build the libraries from source and use them in your own code.

The first half of the book focuses on basic programming interfaces including generic containers and algorithms, strings, resource management, exception safety, and a miscellany of programming utilities that make everyday programming chores easy. Following a short interlude that introduces template metaprogramming and functional programming, the later chapters are devoted to systems programming interfaces, focusing on directory handling, I/O, concurrency, and network programming

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning Boost C++ Libraries an online PDF/ePUB?
Yes, you can access Learning Boost C++ Libraries by Arindam Mukherjee in PDF and/or ePUB format, as well as other popular books in Informatik & Programmierung in C++. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781783551224

Learning Boost C++ Libraries


Table of Contents

Learning Boost C++ Libraries
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introducing Boost
How it all started
What is Boost?
Getting started with Boost libraries
Necessary software
Linux toolchain
Windows toolchain
Obtaining and building Boost libraries
Planning your Boost sandbox
Library naming conventions
Library name components
Library name layouts
Versioned layout
System layout
Tagged layout
Installing a Boost binary distribution
Installing on Windows
Installing on Linux
Building and installing the Boost libraries from source
Optional packages
Building the Boost libraries on Linux
Building the Boost libraries on Windows
Using Boost libraries in your projects
Linking against Boost libraries on Linux
Linking against Boost libraries on Windows
Building the code listings in this book
CMake
Code examples
Self-test questions
Summary
2. The First Brush with Boost's Utilities
Simple data structures
Boost.Optional
Accessing values stored in boost::optional
get_value_or
Boost.Optional versus pointers
Boost.Tuple
Creating tuples
Accessing tuple elements
Comparing tuples
Writing generic code using tuples
Working with heterogeneous values
Boost.Variant
Accessing values in a variant
Compile-time visitation
Generic visitors
Applying visitors to variants in a container
Defining recursive variants
The JSON format
Representing JSON content with recursive variants
Visiting recursive variants
Boost.Any
Boost.Conversion
lexical_cast
Handling command-line arguments
Designing command-line options
The diff command – a case study
Using Boost.Program_Options
Parsing positional parameters
Multiple option values
Other utilities and compile-time checks
BOOST_CURRENT_FUNCTION
Boost.Swap
Compile-time asserts
Diagnostics using preprocessor macros
Self-test questions
Summary
References
3. Memory Management and Exception Safety
Dynamic memory allocation and exception safety
Exception safety and RAII
Smart pointers
Unique ownership semantics
boost::scoped_ptr
Uses of scoped_ptr
Creating exception-safe scopes
Transferring object ownership across functions
As a class member
boost::scoped_array
std::unique_ptr
Ownership transfer using unique_ptr
Wrapping arrays in unique_ptr
make_unique in C++14
Shared ownership semantics
boost::shared_ptr and std::shared_ptr
Uses of shared_ptr
As a class member
Storing dynamically-allocated objects in Standard Library containers
Nonowning aliases – boost::weak_ptr and std::weak_ptr
A shared_ptr critique – make_shared and enable_shared_from_this
Intrusive smart pointers – boost::intrusive_ptr
Using intrusive_ptr
shared_array
Managing non-memory resources using smart pointers
Self-test questions
Summary
References
4. Working with Strings
Text processing with Boost String Algorithms library
Using Boost String Algorithms
Find algorithms
find_first
find_all
find_token
iter_find
find
find_head and find_tail
Other algorithms for testing string properties
Case-conversion and trimming algorithms
Case-conversion algorithms
Trimming algorithms
The replace and erase algorithms
The split and join algorithms
Splitting text using the Boost Tokenizer library
Tokenizing based on separators
Tokenizing records with fields containing metacharacters
Tokenizing records with fixed-length fields
Writing your own tokenizer functions
Regular expressions using Boost.Regex
Regular expression syntax
Atoms
Quantifiers
Character classes
Anchors
Sub-expressions
Disjunctions
Using Boost.Regex to parse regular expressions
Matching text
Searching text
Tokenizing text using regex
Replacing text
Self-test questions
Summary
5. Effective Data Structures beyond STL
Boost Container library
Move-awareness and in-place construction
Nonstandard containers
Flat associative containers
slist
Splicing
stable_vector
static_vector
Fast lookups using Boost Unordered containers
Containers for dynamically-allocated objects
Ownership semantics of pointer containers
Null pointers in pointer containers
Expressive initialization and assignment using Boost.Assign
Assigning lists of values to containers
Initializing containers with lists of values
Initializing pointer containers and assigning values
Iteration patterns using Boost.Iterator
Smart iteration using Boost.Iterator
Filter Iterator
Transform Iterator
Function Output Iterator
Creating conforming iterators for custom classes
Self-test questions
Summary
References
6. Bimap and Multi-index Containers
Containers for multi-criteria lookups
Boost Multi-index containers
Index types
Range lookups using lambda
Insertions and updates
Boost Bimap
Collection types
More ways to use bimaps
Tagged access
Projections
Self-test questions
Summary
References
7. Higher Order and Compile-time Programming
Higher order programming with Boost
Function objects
Lambdas – unnamed function literals
Lambda captures
Delegates and closures
Partial function application
Compile-time programming with Boost
Basic compile-time control flow using templates
Branching
Recursion
Boost Type Traits
SFINAE and enable_if / disable_if
The Boost Metaprogramming Library (MPL)
Metafunctions
Using MPL metafunctions
Domain Specific Embedded Languages
Lazy evaluation
Expression templates
Boost Phoenix
Boost Spirit Parser Framework
Using Spirit Qi
Predefined parsers
The parsing API
Parser operators and expressions
Parsing directives
Semantic actions
Rules
Parsing timestamps
Self-test questions
Summary
References
8. Date and Time Libraries
Date and time calculations with Boost Date Time
Dates from the Gregorian calendar
Creating date objects
Handling date durations
Date periods
Posix time
Constructing time points and durations
Resolution
Time periods
Time iterator
Using Chrono to measure time
Durations
Duration arithmetic
Clocks and time points
Measuring program performance using Boost Timer
cpu_timer
auto_cpu_timer
Self-test questions
Summary
References
9. Files, Directories, and IOStreams
Managing files and directories with Boost Filesystem
Manipulating paths
Printing paths
Constructing paths
Breaking paths into components
Traversing directories
Querying filesystem entries
Performing operations on files
Creating directories
Creating symbolic links
Copying files
Moving and deleting files
Path-aware fstreams
Extensible I/O with Boost IOStreams
Architecture of Boost IOStreams
Using devices
Devices for file I/O
Devices for reading and writing to memory
Using filters
Basic filters
Filters for compression and decompression
Composing filters
Pipelining
Branchin...

Table of contents