Skip to Content
Optimized C++
book

Optimized C++

by Kurt Guntheroth
April 2016
Intermediate to advanced
388 pages
11h 5m
English
O'Reilly Media, Inc.
Content preview from Optimized C++

Chapter 8. Use Better Libraries

A great library is one nobody notices because it is always there, and always has what people need.

Vicki Myron, author of Dewey, the Small Town Library Cat, and librarian of the town of Spencer, Iowa

Libraries are an area of focus in the optimization process. Libraries provide the primitives from which programs are built up. Library functions and classes are often used at the bottom of nested loops, and are thus often hot. Libraries provided by the compiler or operating system command attention to see that they are used efficiently. Project-specific libraries deserve careful design to ensure that they can be used efficiently.

This chapter discusses issues in the use of the C++ standard library, then examines issues in the design of custom libraries that bear on optimization.

Most of Optimized C++ is about tweaking functions to improve performance. This chapter offers instead advice for designers who need to achieve high performance in their initial design, based on my personal experience. Although I introduce this discussion in the context of library design, this section is also a checklist of how good C++ design techniques contribute to good performance.

Optimize Standard Library Use

C++ provides a compact standard library for the following general uses:

  • Determining implementation-dependent behavior, like the largest and smallest values of each numeric type.

  • Functions that might not best be written in C++, like strcpy() and memmove().

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Practical C++ Metaprogramming

Practical C++ Metaprogramming

Edouard Alligand, Joel Falcou
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781491922057Errata Page