ebook img

C++ Standard Library Quick Reference PDF

233 Pages·2016·20.94 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C++ Standard Library Quick Reference

THE EXPERT’S VOICE® IN C++ C++ Standard Library Quick Reference — Peter Van Weert Marc Gregoire C++ Standard Library Quick Reference Peter Van Weert Marc Gregoire C++ Standard Library Quick Reference Peter Van Weert Marc Gregoire Kessel-Lo, Belgium Meldert, Belgium ISBN-13 (pbk): 978-1-4842-1875-4 ISBN-13 (electronic): 978-1-4842-1876-1 DOI 10.1007/978-1-4842-1876-1 Library of Congress Control Number: 2016941348 Copyright © 2016 by Peter Van Weert and Marc Gregoire This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Steve Anglin Technical Reviewer: Bart Vandewoestyne Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing Coordinating Editor: Mark Powers Copy Editor: Tiffany Taylor Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail o [email protected] , or visit w ww.springeronline.com . Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected] , or visit w ww.apress.com . Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at w ww.apress.com/bulk-sales . Any source code or other supplementary materials referenced by the author in this text is available to readers at w ww.apress.com/9781484218754 . For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/ . Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter. Printed on acid-free paper To my parents and my brother and his wife. Th eir support and patience helped me in fi nishing this book. —Marc Gregoire In loving memory of Jeroen. Your enthusiasm and courage will forever remain an inspiration to us all. —Peter Van Weert Contents at a Glance About the Authors ............................................................................xv About the Technical Reviewer .......................................................xvii Introduction ....................................................................................xix ■ Chapter 1: Numerics and Math .......................................................1 ■ Chapter 2: General Utilities ...........................................................23 ■ Chapter 3: Containers ...................................................................51 ■ Chapter 4: Algorithms ..................................................................81 ■ Chapter 5: Stream I/O .................................................................101 ■ Chapter 6: Characters and Strings .............................................125 ■ Chapter 7: Concurrency ..............................................................161 ■ Chapter 8: Diagnostics ...............................................................183 ■ Appendix A: Standard Library Headers ......................................195 Index ..............................................................................................201 v Contents About the Authors ............................................................................xv About the Technical Reviewer .......................................................xvii Introduction ....................................................................................xix ■ Chapter 1: Numerics and Math .......................................................1 Common Mathematical Functions ..............................................<cmath> 1 Basic Functions ........................................................................................................1 Exponential and Logarithmic Functions ...................................................................2 Power Functions .......................................................................................................2 Trigonometric and Hyperbolic Functions ..................................................................2 Error and Gamma Functions .....................................................................................3 Integral Rounding of Floating-Point Numbers ..........................................................3 Floating-Point Manipulation Functions .....................................................................3 Classifi cation and Comparison Functions .................................................................4 Error Handling ...........................................................................................................5 Fixed-Width Integer Types .......................................................<cstdint> 5 Arithmetic Type Properties ......................................................<limits> 5 Complex Numbers ..................................................................<complex> 8 Compile-Time Rational Numbers ..............................................<ratio> 9 Random Numbers ...................................................................<random> 10 Random Number Generators ..................................................................................10 Random Number Distributions ...............................................................................13 vii ■ CONTENTS Numeric Arrays ....................................................................<valarray> 17 std::slice ...........................................................................................................19 std::gslice .........................................................................................................20 std::mask_array ................................................................................................21 std::indirect_array ........................................................................................21 ■ Chapter 2: General Utilities ...........................................................23 Moving, Forwarding, Swapping .............................................<utility> 23 Moving ....................................................................................................................23 Forwarding .............................................................................................................25 Swapping ................................................................................................................26 Pairs and Tuples ....................................................................................26 Pairs....................................................................................................<utility> 26 Tuples .....................................................................................................<tuple> 27 Relational Operators ..............................................................<utility> 28 Smart Pointers .......................................................................<memory> 28 Exclusive-Ownership Pointers ................................................................................29 Shared-Ownership Pointers....................................................................................31 Function Objects .............................................................<functional> 33 Reference Wrappers ...............................................................................................34 Predefi ned Functors ...............................................................................................34 Generic Function Wrappers ....................................................................................35 Binding Function Arguments ..................................................................................36 Functors for Class Members ...................................................................................37 Initializer Lists .......................................................<initializer_list> 39 Date and Time Utilities ...........................................................<chrono> 39 Durations ................................................................................................................40 Time Points .............................................................................................................41 Clocks .....................................................................................................................41 C-style Date and Time Utilities ...............................................................<ctime> 42 viii ■ CONTENTS C-Style File Utilities ................................................................<cstdio> 45 Type Utilities ..........................................................................................45 Runtime Type Identifi cation .....................................<typeinfo>, <typeindex> 45 Type Traits ...................................................................................<type_traits> 46 ■ Chapter 3: Containers ...................................................................51 Iterators ...............................................................................<iterator> 51 Iterator Tags ............................................................................................................52 Non-Member Functions to Get Iterators .................................................................53 Non-Member Operations on Iterators .....................................................................54 Sequential Containers ...........................................................................54 std::vector .......................................................................................<vector> 54 std::deque ...........................................................................................<deque> 60 std::array ...........................................................................................<array> 60 std::list and std::forward_list ......................<list>, <forward_list> 61 Sequential Containers Reference ...........................................................................63 std::bitset .......................................................................................<bitset> 66 Container Adaptors ................................................................................67 std::queue ...........................................................................................<queue> 68 std::priority_queue ........................................................................<queue> 68 std::stack ...........................................................................................<stack> 69 Example ..................................................................................................................69 Reference ...............................................................................................................70 Ordered Associative Containers ............................................................71 std::map and std::multimap .................................................................<map> 71 std::set and std::multiset .................................................................<set> 72 Searching ...............................................................................................................72 Order of Elements ...................................................................................................73 Complexity ..............................................................................................................73 Reference ...............................................................................................................73 ix

Description:
Apress, 2016. — 206 p. — ISBN-10: 1484218752, ISBN-13: 978-1-4842-1875-4.This quick reference is a condensed reference guide to the essential data structures, algorithms, and functions provided by the C++ Standard Library. More specifically, this is a compact collection of essential classes and
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.