background preloader

C++

Facebook Twitter

Cplusplus.com. C++ Reference. This website uses cookies. By continuing, you give permission to deploy cookies, as detailed in our privacy policy. ok Search: Reference Not logged in Reference Standard C++ Library reference C Library The elements of the C language library are also included as a subset of the C++ Standard library.

<cassert> (assert.h) C Diagnostics Library (header) <cctype> (ctype.h) Character handling functions (header) <cerrno> (errno.h) C Errors (header) <cfenv> (fenv.h) Floating-point environment (header) <cfloat> (float.h) Characteristics of floating-point types (header) <cinttypes> (inttypes.h) C integer types (header) <ciso646> (iso646.h) ISO 646 Alternative operator spellings (header) <climits> (limits.h) Sizes of integral types (header) <clocale> (locale.h) C localization library (header) <cmath> (math.h) C numerics library (header) <csetjmp> (setjmp.h) Non local jumps (header) <csignal> (signal.h) C library to handle signals (header) <cstdarg> (stdarg.h) Variable arguments handling (header) <cstdbool> (stdbool.h) Containers. Boost 1.44. Accumulators Framework for incremental calculation, and collection of statistical accumulators. Author(s) Eric Niebler First Release Standard Categories Math and numerics Any Safe, generic container for single values of different value types.

Kevlin Henney Data structures Array STL compliant container wrapper for arrays of constant size. Nicolai Josuttis Containers Asio Portable networking, including sockets, timers, hostname resolution and socket iostreams. Chris Kohlhoff Concurrent Programming, Input/Output Assign Filling containers with constant or generated data has never been easier. Thorsten Ottosen Input/Output Bimap Bidirectional maps library for C++. Matias Capeletto Containers, Data structures Bind boost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. Peter Dimov Function objects and higher-order programming Call Traits Defines types for passing parameters. John Maddock, Howard Hinnant, et al Generic Programming Circular Buffer Jan Gaspar Compatibility Compressed Pair Config Math. Dynamic bitset.

DescriptionSynopsisDefinitionsExamplesRationaleHeader FilesTemplate ParametersConcepts modeled Type requirementsPublic base classesNested type namesPublic data membersConstructorsDestructorMember functionsNon-member functionsException guarantees Changes from previous version(s)See alsoAcknowledgements Description The dynamic_bitset class represents a set of bits. It provides accesses to the value of individual bits via an operator[] and provides all of the bitwise operators that one can apply to builtin integers, such as operator& and operator<<. The number of bits in the set is specified at runtime via a parameter to the constructor of the dynamic_bitset. The dynamic_bitset class is nearly identical to the std::bitset class. The main problem that dynamic_bitset is designed to solve is that of representing a subset of a finite set. Synopsis Definitions Each bit represents either the Boolean value true or false (1 or 0). Examples Example 1 (setting and reading some bits) Rationale None.

Foreach. “Make simple things easy.” -- Larry Wall What is BOOST_FOREACH? In C++, writing a loop that iterates over a sequence is tedious. We can either use iterators, which requires a considerable amount of boiler-plate, or we can use the std::for_each() algorithm and move our loop body into a predicate, which requires no less boiler-plate and forces us to move our logic far from where it will be used. In contrast, some other languages, like Perl, provide a dedicated "foreach" construct that automates this process.

BOOST_FOREACH is just such a construct for C++. BOOST_FOREACH is designed for ease-of-use and efficiency. Hello, world! Below is a sample program that uses BOOST_FOREACH to loop over the contents of a std::string. This program outputs the following: Hello, world! Supported Sequence Types BOOST_FOREACH iterates over sequences. STL containers arrays Null-terminated strings (char and wchar_t) std::pair of iterators Examples Iterate over an STL container: Iterate in reverse: Random. Test. Unordered. For accessing data based on key lookup, the C++ standard library offers std::set, std::map, std::multiset and std::multimap. These are generally implemented using balanced binary trees so that lookup time has logarithmic complexity.

That is generally okay, but in many cases a hash table can perform better, as accessing data has constant complexity, on average. The worst case complexity is linear, but that occurs rarely and with some care, can be avoided. Also, the existing containers require a 'less than' comparison object to order their elements. For some data types this is impossible to implement or isn't practical.

In contrast, a hash table only needs an equality function and a hash function for the key. With this in mind, the C++ Standard Library Technical Report introduced the unordered associative containers, which are implemented using hash tables, and they have now been added to the Working Draft of the C++ Standard. But since the elements aren't ordered, the output of: