6

What is the extent of interoperability between C++11 and a recent version of Boost (say 1.55) built with a C++11 compiler.

  1. Does the behavior of any library feature change depending on whether I built the libraries with c++11 flags enabled or not?
  2. How do language features like lambda functions cooperate with Boost's lambdas?
CppNoob
  • 2,194
  • 22
  • 35
  • Lambda functions and Boost's lambdas don't interfere at all. They are both just function objects. Only C++11 lambdas are compiler generated, and Boost uses expression templates. – sehe Mar 26 '14 at 12:55
  • Related: https://stackoverflow.com/a/49119902/23715 – Alex Che Sep 21 '18 at 11:21

2 Answers2

6
  1. You cannot use objects built with gcc with and without -std=c++11 together. You will get link errors or even runtime crashes. I cannot vouch for other C++ implementations. So at least with gcc, you do need to build a separate version of Boost with c++11 mode enabled.
  2. They are pretty much independent. They don't cooperate and don't interfere with each other.

EDIT I see people are still reading (and upvoting!) this answer. Point 1 is no longer true (or perhaps never was true). Versions of gcc from I think 5.1 upwards use an ABI compatible with -std=<anything> by default.

n. 1.8e9-where's-my-share m.
  • 102,958
  • 14
  • 123
  • 225
2

No behaviours change: at the code level Boost is compatible with both C++03 and C++11.

However, at the object level you won't be able to mix and match: if your program is compiled as C++11, and you're using some non-header Boost libraries, you will have to build those Boost libraries as C++11 as well. This is because the respective C++ runtimes of your toolchain for each version of the language cannot be guaranteed to have ABI compatibility.

Lightness Races in Orbit
  • 369,052
  • 73
  • 620
  • 1,021