⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bimap_and_boost.qbk

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 QBK
📖 第 1 页 / 共 2 页
字号:
boost::_1 from Boost.Bind.[import ../example/bimap_and_boost/lambda.cpp][@../../example/bimap_and_boost/lambda.cpp Go to source code][code_bimap_and_boost_lambda][endsect][section Boost.Range]Boost.Range is a collection of concepts and utilities that are particularly usefulfor specifying and implementing generic algorithms.Generic algorithms have so far been specified in terms of two or more iterators.Two iterators would together form a range of values that the algorithm couldwork on. This leads to a very general interface, but also to a somewhat clumsyuse of the algorithms with redundant specification of container names. Thereforewe would like to raise the abstraction level for algorithms so they specify theirinterface in terms of Ranges as much as possible.As Boost.Bimap views are signature-compatible with their standardcontainer counterparts, they are compatible with the concept of a range.As an additional feature, ordered bimap views offer a function named`range` that allows a range of values to be obtained.[import ../example/bimap_and_boost/range.cpp]If we have some generic functions that accepts ranges:[code_bimap_and_boost_range_functions]We can use them with Boost.Bimap with the help of the `range` function.[code_bimap_and_boost_range][@../../example/bimap_and_boost/range.cpp Go to source code][endsect][section Boost.Foreach]In C++, writing a loop that iterates over a sequence is tedious.We can either use iterators, which requires a considerable amount ofboiler-plate, or we can use the std::for_each()  algorithm and move ourloop body into a predicate, which requires no less boiler-plate and forcesus to move our logic far from where it will be used. In contrast, some otherlanguages, like Perl, provide a dedicated "foreach" construct that automatesthis process. BOOST_FOREACH is just such a construct for C++. It iteratesover sequences for us, freeing us from having to deal directly with iteratorsor write predicates.You can use BOOST_FOREACH macro with Boost.Bimap views. The generated code willbe as efficient as a std::for_each iteration.Here are some examples:[import ../example/bimap_and_boost/foreach.cpp][code_bimap_and_boost_foreach]You can use it directly with ranges too:[code_bimap_and_boost_foreach_using_range][@../../example/bimap_and_boost/foreach.cpp Go to source code][endsect][section Boost.Typeof][import ../example/bimap_and_boost/typeof.cpp]Once C++0x is out we are going to be able to write code like:    auto iter = bm.by<name>().find("john");instead of the more verbose    bm_type::map_by<name>::iterator iter = bm.by<name>().find("john");Boost.Typeof defines a macro BOOST_AUTO that can be used as a librarysolution to the auto keyword while we wait for the next standard.If we have[code_bimap_and_boost_typeof_first]The following code snippet[code_bimap_and_boost_typeof_not_using_auto]can be rewrited as[code_bimap_and_boost_typeof_using_auto][@../../example/bimap_and_boost/typeof.cpp Go to source code][endsect][section Boost.Xpressive][import ../example/bimap_and_boost/xpressive.cpp]Using Boost.Xpressive we can parse a file and insert the relations in a bimapin the same step. It is just amazing the power of four lines of code.Here is an example (it is just beatifull)[code_bimap_and_boost_xpressive][@../../example/bimap_and_boost/xpressive.cpp Go to source code][endsect][section Boost.Property_map]The Boost Property Map Library consists mainly of interface specifications in the form ofconcepts (similar to the iterator concepts in the STL). These interface specificationsare intended for use by implementers of generic libraries in communicating requirements ontemplate parameters to their users. In particular, the Boost Property Map concepts define ageneral purpose interface for mapping key objects to corresponding value objects, therebyhiding the details of how the mapping is implemented from algorithms.The need for the property map interface came from the Boost Graph Library (BGL), whichcontains many examples of algorithms that use the property map concepts to specify theirinterface. For an example, note the ColorMap template parameter of the  breadth_first_search.In addition, the BGL contains many examples of concrete types that implement the property mapinterface. The  adjacency_list class implements property maps for accessing objects(properties) that are attached to vertices and edges of the graph.The counterparts of two of the views of Boost.Bimap map, the `set` and`unordered_set`, are read-write property maps. In order to use these, youneed to include one of the following headers:    #include <boost/bimap/property_map/set_support.hpp>    #include <boost/bimap/property_map/unordered_set_support.hpp>The following is adapted from the example in the Boost.PropertyMapdocumentation.[import ../example/bimap_and_boost/property_map.cpp][@../../example/bimap_and_boost/property_map.cpp Go to source code][code_bimap_and_boost_property_map][endsect][endsect][section Dependencies]Boost.Bimap is built on top of several Boost libraries. The rationalebehind this decision is keeping the Boost code base small by reusingexistent code. The libraries used are well-established and have beentested extensively, making this library easy to port since all the hardwork has already been done. The glue that holds everything together isBoost.MPL. Clearly Boost.MultiIndex is the heart of this library.[table Boost Libraries needed by Boost.Bimap[[Name][Description][author]][[ __BOOST_MULTI_INDEX__ ][Containers with multiple STL-compatible access interfaces][Joaquín M López Muñoz]][[ __BOOST_MPL__ ][Template metaprogramming framework of compile-time algorithms, sequences and metafunction classes][Aleksey Gurtovoy]][[ __BOOST_TYPE_TRAITS__ ][Templates for fundamental properties of types.][John Maddock, Steve Cleary]][[ __BOOST_ENABLE_IF__ ][Selective inclusion of function template overloads][Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine]][[ __BOOST_ITERATORS__ ][Iterator construction framework, adaptors, concepts, and more.][Dave Abrahams, Jeremy Siek, Thomas Witt]][[ __BOOST_CALL_TRAITS__ ][Defines types for passing parameters.][John Maddock, Howard Hinnant]][[ __BOOST_STATIC_ASSERT__ ][Static assertions (compile time assertions).][John Maddock]]][table Optional Boost Libraries[[Name][Description][author][Purpose]][[ __BOOST_SERIALIZATION__ ][Serialization for persistence and marshalling][Robert Ramey][Serialization support for bimap containers and iterators]][[ __BOOST_ASSIGN__ ][Filling containers with constant or generated data has never been easier][Thorsten Ottosen][Help to fill a bimap or views of it]][[ __BOOST_HASH__ ][A TR1 hash function object that can be extended to hash user defined types][Daniel James][Default hashing function]][[ __BOOST_LAMBDA__ ][Define small unnamed function objects at the actual call site, and more][from Jaakko Järvi, Gary Powell][Functors for modify, range, lower_bound and upper_bound]][[ __BOOST_RANGE__ ][A new infrastructure for generic algorithms that builds on top of the newiterator concepts][Thorsten Ottosen][Range based algorithms]][[ __BOOST_PROPERTY_MAP__ ][Concepts defining interfaces which map key objects to value objects][Jeremy Siek][Integration with BGL]]][table Additional Boost Libraries needed to run the test-suite[[Name][Description][author]][[ __BOOST_TEST__ ][Support for simple program testing, full unit testing, and for program execution monitoring.][Gennadiy Rozental]]][endsect][endsect]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -