Using Boost on ubuntu

后端 未结 8 1136
北恋
北恋 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::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.

提交回复
热议问题