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

📄 history.qbk

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 QBK
📖 第 1 页 / 共 2 页
字号:
[/licenseBoost.BimapCopyright (c) 2006-2007 Matias CapelettoDistributed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy athttp://www.boost.org/LICENSE_1_0.txt)][/ QuickBook Document version 1.4 ][section History][section The long path from Code Project to Boost][variablelist[[2002 - bimap at Code Project][Joaquin Lopez Muñoz posted his first [@http://www.codeproject.com/vcpp/stl/bimap.asp#test_suite bimap library]in 2002. Tons of users have been using it. He then[@http://aspn.activestate.com/ASPN/Mail/Message/boost/1404881 asked thelist for interest] in his library in 2003. Luckily, there was a lot ofinterest and Joaquin started to boostify the code. At some point all thedevelopers seemed to agree that, rather than a bidirectional map, it wouldbe better to work on an N-indexed set that contained Joaquin's library as aparticular case.]][[2003 - multiindex_set][The library grew enormously and was ready for a formal review in2003. At this point, the container was a lot more powerful, buteverything comes with a price and this new beast lacked the simplicityof the original bimap.]][[2004 - indexed_set][In 2004, the formal review ended well for the new multi-indexedcontainer. This Swiss army knife introduced several new features, suchas non-unique indexes, hashed indices and sequenced indices. In the listof improvements to the library, it was mentioned that a bidirectionalmap should be coded in top of this container.]][[2005 - multi_index_container][Once in Boost, the library switched to the now familiar name"Boost.MultiIndex". Late in 2004, it formally became a member of Boost.Joaquin continued to enchance the library and added new features such ascomposite keys and random-access indices.]][[2006 - Multi Index Specialized Containers SoC project][In 2006, during the formal review of Boost.Property_tree, the needfor a bidirectional map container built on top of Boost.MultiIndex aroseagain. Boost entered the Google SoC 2006 as a mentor organization at thesame time. Joaquin put himself forward as a mentor. He proposed to buildnot only a bidirectional map, but a myriad multi-indexed specializedcontainers. Matias Capeletto presented an application to code Boost.Miscfor the SoC and was elected, along with nine other students. Matias's andJoaquin's SoC project ends with a working implementation of the bimaplibrary that was presented in an informal review. By the end of the yearthe library was queued for a formal review.]][[2007 - Boost.Bimap][The formal review took place at the beggining of the year and Boost.Bimap was accepted in Boost.]]][endsect][section MultiIndex and Bimap]This is the conversation thread that began during Boost.PropertyTree formalreview process. The review was very interesting and very deep topics were addressed. It is quite interesting and it is now part of this library history.Enjoy![*Marcin][:['The biggest virtue of property_tree is easy to use interface.If we try to make generic tree of it, it will be compromised.]][*Gennadiy][:['IMO the same result (as library presents) could be achievedjust by using multi_index.]][*Marcin][:['Could you elaborate more on that? I considered use ofmulti_index to implement indexing for properties, but it only affected theimplementation part of library, not interface, and because I already had aworking, exception safe solution, I didn't see the reason to dump it and addanother dependency on another library.]][*Gennadiy][:['I mean why do I need this half baked property_tree as anotherdata structure? Property tree supports nothing in itself. It's just a datastructure. You have parsers that produce property tree out of different sources.But you mat as well produce maps or something else. Here for example All thatI need to do to "implement" similar functionality as your property tree:]]``// Data structure itselftemplate<typename ValueType,typename KeyType>struct Node;template<typename ValueType,typename KeyType>struct ptree_gen {    typedef std::pair<KeyType,Node<ValueType,KeyType> > mi_value;    typedef multi_index_container<mi_value, indexed_by<...> > type;};template<typename ValueType,typename KeyType>struct Node {    ValueType v;    ptree_gen<ValueType,KeyType>::type children;};// serialization supporttemplate<class Archive,typename ValueType,typename KeyType>void serialize(Archive & ar, Node<ValueType,KeyType>& n,               const unsigned int version){    ar & n.v;    ar & n.children;}// some access methodstemplate<typename ValueType,typename KeyType>ValueType const&get( string const& keys, ptree_gen<ValueType,KeyType>::type const& src ){    std::pait<string,string> sk = split( keys, "." );    Node const& N = src.find( sk.first );    return sk.second.empty() ? N.v : get( sk.second, N.children );}``[:['Use it like this:]]``ptree_gen<string,string>::type PT;boost::archive::text_iarchive ia( std::ifstream ifs("filename") );ia >> PT;string value = get( "a.b.c.d", PT );``[:['Now tell me how property_tree interface is easier? And what is the value in50k of Code you need to implement this data structure.]][*Thorsten][:['Seriously Gennadiy, do you really see newbies writingthe code you just did?]][*Marcin][:['What you just implemented is stripped down, bare bones versionof property_tree that, among other things, does not allow you to produce humaneditable XML files. Now add more interface (aka get functions), add morearchives to serialization lib, add customization, add transparenttranslation from strings to arbitrary types and vice versa. Spend some weekstrying to get all the corner cases right, and then some more weeks trying tosmooth rough edges in the interface. Then write tests. Write docs. At theend, I believe you will not get much less code than there is in the libraryalready. Maybe you get some savings by using multi_index instead of manualindexing.]][:['The reason why ptree does not use multi index is because implementationexisted long before I considered submitting to boost, probably before even Iknew of multi index existence. It was working well. Later, when I wasimproving it during pre-review process, I seriously considered usingmulti-index. But I decided it is not worth throwing everything out.]][:['Although ptree has large interface with many functions modifying state ofthe tree, it uses "single point of change" approach. Every insert eventuallygoes through one function, which takes care of exception safety and keepingindex in sync with data. The same applies to erase. This function has 9lines of code in case of insert, and (by coincidence) also 9 in case oferase. By using multi index these functions would obviously be simplified,maybe to 4 lines each. Net gain: 10 lines of code (out of several hundred inptree_implementation.hpp).]][:['I'm aware that there are performance gains to be reaped as well, but at thattime I was rather focusing on getting the interface right.]][*Dave][:['That's perfectly reasonable, but (through no fault of yours) it misses the point I was trying to make.  I guess I should have said,"...that demonstrates it to be the best implementation."]][:['All I'm saying is that the extent to which a Boost libraryimplementation should leverage other Boost libraries is not a questionthat can always be decided based on following simple guidelines, andthat if this library is accepted, it's worth revisiting your decision.]][*Thorsten][:['I think it is important to focus on the interface in the review, but I also see several benefits of an implementation that builds onBoost.MultiIndex:'

⌨️ 快捷键说明

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