`
ruilinruirui
  • 浏览: 1048992 次
文章分类
社区版块
存档分类
最新评论

Getting Started with Boost

 
阅读更多
1. Boost是什么
Boost库是一个可移植、提供源代码的C++库,其覆盖了广泛的领域,从数学库到智能指针,从模板元编程库到预处理器库,从线程到lambda表达式等等。
Ten
Boost libraries are already included in the C++ Standards Committee's Library Technical Report (TR1) and will be in the new C++0x Standard now being finalized. C++0x will also include several more Boost libraries in addition to those from TR1. More Boost libraries are proposed for TR2.

2. Boost包含哪些东西

Accumulators : Framework for incremental calculation, and collection of statistical accumulators.
Any : Safe, generic container for single values of different value types.
Array : STL compliant container wrapper for arrays of constant size.
Asio : Portable networking, including sockets, timers, hostname resolution and socket iostreams.
Assign : Filling containers with constant or generated data has never been easier.
Bimap : Bidirectional maps library for C++. With Boost.Bimap you can create associative containers in which both types can be used as key.
Bind : bost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions.
Call Traits : Defines types for passing parameters.
Chrono : Useful time utilities.
Circular Buffer : A STL compliant container also known as ring or cyclic buffer.
Compatibility : Help for non-conforming standard libraries.
Compressed Pair : Empty member optimization.
Concept Check : Tools for generic programming.
Config : Helps Boost library developers adapt to compiler idiosyncrasies; not intended for library users.
Conversion : Polymorphic and lexical casts.
CRC : The Boost CRC Library provides two implementations of CRC (cyclic redundancy code) computation objects and two implementations of CRC computation functions. The implementations are template-based.
Date Time : A set of date-time libraries based on generic programming concepts.
Disjoint Sets : Boost.DisjointSets provides disjoint sets operations with union by rank and path compression.
Dynamic Bitset : 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.
Enable If : Selective inclusion of function template overloads.
Exception : The Boost Exception library supports transporting of arbitrary data in exception objects, and transporting of exceptions between threads.
Filesystem : The Boost Filesystem Library provides portable facilities to query and manipulate paths, files, and directories.
Flyweight : Design pattern to manage large quantities of highly redundant objects.
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++. It iterates over sequences for us, freeing us from having to deal directly with iterators or write predicates.
Format : The format library provides a class for formatting arguments according to a format-string, as does printf, but with two major differences: format sends the arguments to an internal stream, and so is entirely type-safe and naturally supports all user-defined types; the ellipsis (...) can not be used correctly in the strongly typed context of format, and thus the function call with arbitrary arguments is replaced by successive calls to an argument feeding operator%.
Function : Function object wrappers for deferred calls or callbacks.
Function Types : Boost.FunctionTypes provides functionality to classify, decompose and synthesize function, function pointer, function reference and pointer to member types.
Functional : The Boost.Function library contains a family of class templates that are function object wrappers.
Functional/Factory : Function object templates for dynamic and static object creation
Functional/Forward : Adapters to allow generic function objects to accept arbitrary arguments
Functional/Hash : A TR1 hash function object that can be extended to hash user defined types.
Fusion : Library for working with tuples, including various containers, algorithms, etc.
Geometry : Geometry Library.
GIL : Generic Image Library
Graph : The BGL graph interface and graph components are generic, in the same sense as the the Standard Template Library (STL).
ICL : Interval Container Library, interval sets and maps and aggregation of associated values
In Place Factory, Typed In Place Factory : Generic in-place construction of contained objects with a variadic argument-list.
Integer : The organization of boost integer headers and classes is designed to take advantage of <stdint.h> types from the 1999 C standard without resorting to undefined behavior in terms of the 1998 C++ standard. The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace boost without placing any names in namespace std.
Interprocess : Shared memory, memory mapped files, process-shared mutexes, condition variables, containers and allocators.
Interval : Extends the usual arithmetic functions to mathematical intervals.
Intrusive : Intrusive containers and algorithms.
IO State Savers : The I/O sub-library of Boost helps segregate the large number of Boost headers. This sub-library should contain various items to use with/for the standard I/O library.
Iostreams : Boost.IOStreams provides a framework for defining streams, stream buffers and i/o filters.
Iterators : The Boost Iterator Library contains two parts. The first is a system of concepts which extend the C++ standard iterator requirements. The second is a framework of components for building iterators based on these extended concepts and includes several useful iterator adaptors.
Lambda : Define small unnamed function objects at the actual call site, and more.
Lexical Cast : General literal text conversions, such as an int represented a string, or vice-versa, from Kevlin Henney.
Math : Boost.Math includes several contributions in the domain of mathematics: The Greatest Common Divisor and Least Common Multiple library provides run-time and compile-time evaluation of the greatest common divisor (GCD) or least common multiple (LCM) of two integers. The Special Functions library currently provides eight templated special functions, in namespace boost. The Complex Number Inverse Trigonometric Functions are the inverses of trigonometric functions currently present in the C++ standard. Quaternions are a relative of complex numbers often used to parameterise rotations in three dimentional space. Octonions, like quaternions, are a relative of complex numbers.
Math Common Factor : Greatest common divisor and least common multiple.
Math Octonion : Octonions.
Math Quaternion : Quaternions.
Math/Special Functions : A wide selection of mathematical special functions.
MMember Function : Generalized binders for function/object/pointers and member functions.
Meta State Machine : A very high-performance library for expressive UML2 finite state machines.
Min-Max : Standard library extensions for simultaneous min/max and min/max element computations.
MPI : Message Passing Interface library, for use in distributed-memory parallel application programming.
MPL : The Boost.MPL library is a general-purpose, high-level C++ template metaprogramming framework of compile-time algorithms, sequences and metafunctions. It provides a conceptual foundation and an extensive set of powerful and coherent tools that make doing explict metaprogramming in C++ as easy and enjoyable as possible within the current language.
Multi-Array : Boost.MultiArray provides a generic N-dimensional array concept definition and common implementations of that interface.
Multi-Index : The Boost Multi-index Containers Library provides a class template named multi_index_container which enables the construction of containers maintaining one or more indices with different sorting and access semantics.
Numeric Conversion : Optimized Policy-based Numeric Conversions.
Operators : Templates ease arithmetic classes and iterators.
Optional : Discriminated-union wrapper for optional values.
Parameter : Boost.Parameter Library - Write functions that accept arguments by name.
Phoenix : Define small unnamed function objects at the actual call site, and more.
Pointer Container : Containers for storing heap-allocated polymorphic objects to ease OO-programming.
Polygon : Booleans/clipping, resizing/offsetting and more for planar polygons with integral coordinates.
Pool : Memory pool management.
Preprocessor : Preprocessor metaprogramming tools including repetition and recursion.
Program Options : The program_options library allows program developers to obtain program options, that is (name, value) pairs from the user, via conventional methods such as command line and config file.
Property Map : Concepts defining interfaces which map key objects to value objects.
Property Tree : A tree data structure especially suited to storing configuration data.
Proto : Expression template library and compiler construction toolkit for domain-specific embedded languages.
Python : The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler.
Random : A complete system for random number generation.
Range : A new infrastructure for generic algorithms that builds on top of the new iterator concepts.
Ratio : Compile time rational arithmetic.
Rational : A rational number class.
Ref : A utility library for passing references to generic functions.
Regex : Regular expression library.
Result Of : Determines the type of a function call expression.
Scope Exit : Execute arbitrary code at scope exit.
Serialization : Serialization for persistence and marshalling.
Signals : Managed signals & slots callback implementation.
Signals2 : Managed signals & slots callback implementation (thread-safe version 2).
Smart Ptr : Smart pointer class templates.
Spirit : LL parser framework represents parsers directly as EBNF grammars in inlined C++.
Statechart : Boost.Statechart - Arbitrarily complex finite state machines can be implemented in easily readable and maintainable C++ code.
Static Assert : Static assertions (compile time assertions).
String Algo : String algorithms library.
Swap : Enhanced generic swap function.
System : Operating system support, including the diagnostics support that will be part of the C++0x standard library.
Test : Support for simple program testing, full unit testing, and for program execution monitoring.
Thread : Portable C++ multi-threading.
Timer : Event timer, progress timer, and progress display classes.
Tokenizer : Break of a string or other character sequence into a series of tokens.
TR1 : The TR1 library provides an implementation of the C++ Technical Report on Standard Library Extensions. This library does not itself implement the TR1 components, rather it's a thin wrapper that will include your standard library's TR1 implementation (if it has one), otherwise it will include the Boost Library equivalents, and import them into namespace std::tr1.
Tribool : 3-state boolean type library.
Tuple : Ease definition of functions returning multiple values, and more.
Type Traits : Templates for fundamental properties of types.
Typeof : Typeof operator emulation.
uBLAS : uBLAS provides matrix and vector classes as well as basic linear algebra routines. Several dense, packed and sparse storage schemes are supported.
Units : Zero-overhead dimensional analysis and unit/quantity manipulation and conversion.
Unordered : Unordered associative containers.
Utility : Class noncopyable plus checked_delete(), checked_array_delete(), next(), prior() function templates, plus base-from-member idiom.
Uuid : A universally unique identifier.
Value Initialized : Wrapper for uniform-syntax value initialization, based on the original idea of David Abrahams.
Variant : Safe, generic, stack-based discriminated union container.
Wave : The Boost.Wave library is a Standards conformant, and highly configurable implementation of the mandated C99/C++ preprocessor functionality packed behind an easy to use iterator interface.
Xpressive : Regular expressions that can be written as strings or as expression templates, and which can refer to each other and themselves recursively with the power of context-free grammars.

3. 使用Boost
Most Boost libraries are header-only: they consist entirelyof header files containing templates and inline functions, andrequire no separately-compiled library binaries or specialtreatment when linking.
The only Boost libraries that must be built separately are:
Boost.Filesystem
Boost.GraphParallel
Boost.IOStreams
Boost.MPI
Boost.ProgramOptions
Boost.Python (see the Boost.Python build documentationbefore building and installing it)
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.System
Boost.Thread
Boost.Wave

A few libraries have optional separately-compiled binaries:
Boost.DateTime has a binary component that is only needed ifyou're using its to_string/from_string or serializationfeatures, or if you're targeting Visual C++ 6.x or Borland.
Boost.Graph also has a binary component that is only needed ifyou intend to parse GraphViz files.
Boost.Math has binary components for the TR1 and C99cmath functions.
Boost.Random has a binary component which is only needed ifyou're using random_device.
Boost.Test can be used in “header-only” or “separately compiled”mode, although separate compilation is recommended for serioususe.

4. 参考
http://www.boost.org/
Beyond the C++ Standard Library: An Introduction to Boost

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics