7

Does pybind11 work for C++14 and C++17 seamlessly ?

I'm planning to use Boost.python for my project which is currently in C++11. In future I may have to upgrade to C++14 or C++17. So I wanted to understand what will be the right choice here - boost.python ot pybind11.

From pybind11 doc, it says - "seamless operability between C++11 and Python" So bit confused

Vinu
  • 147
  • 1
  • 7
  • 1
    I would assume that it needs 11 at a minimum but just works with later editions. – Botje Sep 01 '20 at 08:05
  • I'm confused to decide between boost.python and pybind11. Can you help – Vinu Sep 01 '20 at 08:22
  • How? You haven't told us what your requirements are beyond "must work with c++14 or c++17". I would assume both will work, so that is not a valid decision point. – Botje Sep 01 '20 at 08:31
  • It already supports some of C++17 new features: https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#c-17-library-containers; Anyway, C++ standards are generally backward compatible – pptaszni Sep 01 '20 at 09:20
  • @Botje I have a c++ library (subscribes to a middleware, receives updates and deserialize the data). I have to write a python wrapper over it to be used by python clients. – Vinu Sep 01 '20 at 09:41
  • @botje Creating a pure virtual class in C++ and having its implementation in python, passing this object as a param to C++ class etcs are my use cases which works with Boost.python. Not sure if this will work in pybind11 – Vinu Sep 01 '20 at 09:42
  • Seems like you have already figured out which library to use. – Botje Sep 01 '20 at 09:46
  • No, I am just evaluating if these things are possible. I got to know everything is possible using Boost.python and yet to do in pybind11. I believe these are supported in pybind11 too – Vinu Sep 01 '20 at 09:53

1 Answers1

12

Yes, it works with C++11/14/17/20, see corresponding section in docs.

By default, pybind11 will compile modules with the compiler default or the minimum standard required by pybind11, whichever is higher.

Sergei
  • 1,599
  • 12
  • 21