let's take a look at the boost libraries

10
Let’s Take A Look At The Boost Libraries Seoul System Programmers Network #6 @TomSmartBishop Thomas Pollak

Upload: thomas-pollak

Post on 13-Apr-2017

51 views

Category:

Technology


2 download

TRANSCRIPT

C++ Core Guidelines

Lets Take A Look At The Boost LibrariesSeoul System Programmers Network #6

@TomSmartBishop Thomas Pollak

Setup Boost (currently v1.61)Download and unzip (http://www.boost.org/users/download/)Run bootstrap(.bat|.sh)Run b2 to generate the libs for your toolchainWithout parameters b2 will try to auto-detect your toolchainIn case you would like to build for another platform or b2 has troubles use --help to see all optionsLibs will be in the sub directory stage/lib, you can move/install everything to the default locations with b2 install

Lets look at the samplesYou can find the source code here: https://github.com/TomSmartBishop/sspn_06_lets_boostI picked 7 boost libraries that I found interesting and used some more as little helpers, but there is much more: http://www.boost.org/users/history/version_1_61_0.html Most libraries are header only and make heavy use of templates (and macros). Samples that need library linkage are pointed out on the slides.Be aware that there s a compile time overhead, also for small samples.Due to the fact that most boost libraries have different authors the API seems not always homogenous (however there are core components used across all libs).Sometimes the API feels sometimes a bit over-engineered but does work as expected (compared to the STL lib). In VS2015 /Wall produces a lot warnings so that /W4 seems like a better choice.

Boost Program Optionshttp://www.boost.org/doc/libs/1_61_0/doc/html/program_options.htmlIn case you are writing a program with command line parameters this is quite useful. No need to re-implement boring stuff again and again. The github sample uses the program options also to switch between the other sample implementations.Needs to be linked against the program_options library.po::options_description desc("Allowed options");desc.add_options() ("help", "produce help message") ("compression", po::value(), "set compression level");

po::variables_map vm;po::store(po::parse_command_line(ac, av, desc), vm);po::notify(vm);

if (vm.count("help")) cout