Bootstrapped by Boost

@thomasguest

wordaligned.org

@clinithinkwales

YES

YEAH

Bootstrapped by Boost


//! Return the {target => source} map of prescribed substances
std::unordered_map<int, int> Graph::ConsumesSources() const
{
  std::unordered_map<int, int> target_sources;

  boost::insert(target_sources,
     edges_
     | boost::adaptors::filtered
       (std::function<bool(Edge)>
       ([](auto const & e){ return e.type_ == Consumes; }))
     | boost::adaptors::transformed
       (std::function<std::pair<int, int>(Edge const &)>
       ([](auto const & e) { return std::make_pair(e.to_, e.from_); })
     ));

  return target_sources;
}

std::unordered_map<int, int>
Graph::ConsumesSources() const
{
  std::unordered_map<int, int> target_sources;

  for (auto const & edge : edges_)
  {
    if (edge.type_ == Consumes)
      target_sources.insert({edge.to_, edge.from_});
  }

  return target_sources;
}

    def ConsumesSources(self):
        return { edge.to_: edge.from_
                 for edge in self.edges_
                 if edge.type_ == Consumes }

I know how complex that looks and to be honest I havenโ€™t used it in real code yet but I think itโ€™s interesting to at least know whatโ€™s in there [...] to get inspiration.

— Jonathan Boccara, Learning C++ Boost: Boost Karma

Bootstrapped by Boost

Boos!!! Trapped by Boost!!

Agenda

  • Thomas ~ Who?
  • Clinithink ~ What?
  • Boost ~ Why? Where? How?
  • Boost ~ Next?

Thomas ~ Who?

Thomas works @ClinithinkWales wrestling meaning from medical records ๐Ÿ“. He likes puzzles, running and noodles. ๐Ÿงฉ๐Ÿƒ๐Ÿœ

Casino solved

Clinithink ~ What?

Architecture

Inputs

Inputs

Processing

Output

Boost ~ Why? Where? How?

Intro ~ Install ~ Spirit ~ Python ~ Interprocess

Advantages

  • ๐ŸŽ‚ happy 20th birthday
  • ๐Ÿ‘œ portable
  • ๐Ÿƒโ€โ™€๏ธ active
  • ๐Ÿง peer reviewed
  • ๐Ÿงพ permissive license
  • โ™ป๏ธ styled on std

Challenges

  • โ›๏ธ tough on toolchains
  • ๐Ÿ˜ผ uncompromising
  • ๐Ÿ˜๏ธ monolithic but disparate
  • โšก extremely C++
  • ๐Ÿ” not SO friendly
  • ๐Ÿ“‘ documentation

Boost.Size

$ ls -hs boost_1_69_0.7z 
79M boost_1_69_0.7z
$ 7z l boost_1_69_0.7z | wc -l
66850
      

Boost off

sed s/boost/std/g
sed s/boost//g
Mary Poppins

Boost graduates

bind ~ filesystem ~ function ~ optional ~ range ~ regex ~ smart_ptr ~ thread ~ unordered_map/set ~ thread ~ tuple ~ variant ~ etc ~ etc

Graduate celebrations

Boost drop outs

noncopyable assign ...

Boost Where

algorithm any archive asio assign bind date_time filesystem foreach format function functional fusion graph interprocess iostreams iterator lambda lexical_cast log mem_fn multi-index optional phoenix pool program_options progress property_map property_tree python range regex serialization spirit string-algorithms thread timer tokenizer tuple unittest unordered_map unordered_set uuid variant

Using Boost

Most libraries are header only.

Filesystem, graph, iostreams, log, python, random, regex, serialisation, timer, unittest require building.

Build/Install Boost

  • use a package manager
  • use Boost.Build
  • DiY

Boost.Build

7z x boost_1_69_0.7z && ^
cd boost_1_69_0 && bootstrap.bat && ^
bjam -j8 toolset=msvc-14.1 ^
-s BZIP2_SOURCE=c:/bzip2/bzip2-1.0.6 ^
-s ZLIB_SOURCE=c:/zlib/zlib-1.2.11 ^
--build-type=complete ^
address-model=64 architecture=x86 threading=multi ^
--prefix=d:/boost64 install
      

Boost.Spirit

  • Boost Spirit is a parser and output generator.
  • You write grammars and format descriptions using EBNF directly in C++ โ˜ฏ๏ธ
  • [†] well, almost

DEMO

Boost.Python

Boost.Python enables seamless interoperability between C++ and Python.

Boost.Python

The libraryโ€™s use of advanced metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).

๐Ÿง๐Ÿค”๐Ÿ˜•

PyBind11

The main issue with Boost.Python—and the reason for creating such a similar project—is Boost

See also: YAS

DEMO

Boost.Interprocess

Boost.Interprocess simplifies the use of common interprocess communication and synchronization mechanisms. Support includes: shared memory, memory-mapped files, semaphores, mutexes ... message queues.

DEMO

Boost ~ Next

(Some algorithms and containers weโ€™ve either hand-rolled or shopped elsewhere)

(Not mentioning graphics libraries, UI toolkits, games engines, web servers ...)

Thank you!

@thomasguest

@clinithinkwales

wordaligned.org