Using Boost on ubuntu

后端 未结 8 1003
北恋
北恋 2020-12-29 08:57

I\'ve heard a lot of good comments about Boost in the past and thought I would give it a try. So I downloaded all the required packages from the package manager in Ubuntu 9.

相关标签:
8条回答
  • 2020-12-29 09:37

    Using Easypeasy 1.1 (for netbooks) which is based upon Ubuntu I was able to use Synaptic Package Manager to install, I believe, libboost-dev. Then simply by adding:

    #include "boost/foreach.hpp"
    

    I was able to replace the existing lines in an existing application (which has an Ask class which has nothing to do with boost):

    for (std::vector<Ask*>::iterator ii=ui.begin(); ii!=ui.end(); ++ii)
        std::cout << (*ii)->prompt() << (*ii)->answer() << std::endl;
    

    with:

    BOOST_FOREACH (Ask* ii, ui)
         std::cout << ii->prompt() << ii->answer() << std::endl;
    

    As I understand it this is a header only feature. I have not used anything requiring link time changes yet.

    0 讨论(0)
  • 2020-12-29 09:45

    The library documentation is a mixed bag. Some is good, but some is more of a reference than a guide. The best guide to (some of) the Boost libraries is the book Beyond the C++ Standard Library. At the very least, the introduction gives one paragraph descriptions of many of the libraries. From there, you can decide which library is most important for your current needs, and, if it's in the book, read the chapter on it, or read the documentation on the website.

    If you read German, there's a good online guide. Google translate does a good enough job that a non-speaker like me can understand it.

    Also, unless you have lots of experience with C++, I'd start with the simpler libraries (e.g. smart_ptr, tuple, conversion, tokenizer, regex, date_time, test), before trying the more complicated ones (bind, variant, any), or the really advanced ones (concepts, MPL, Fusion).

    0 讨论(0)
  • 2020-12-29 09:45

    The libraries come with documentation and many of them have tutorials as part of the documentation. Just start reading.

    0 讨论(0)
  • 2020-12-29 09:55

    I was just looking at that german boost guide, and found there was an english one as well (same book). It looks pretty good, have just read the introductory pages which are quite useful

    0 讨论(0)
  • 2020-12-29 09:55

    The best tutorial I've read so far are those two books:

    • Introduction to the Boost C++ Libraries; Volume I - Foundations
    • Introduction to the Boost C++ Libraries; Volume II - Advanced Libraries
    0 讨论(0)
  • 2020-12-29 09:56

    The Boost website has some good tutorials, they are just kind of hidden.

    0 讨论(0)
提交回复
热议问题