Search code examples
c++boostc++20gcc11

Boost concept check warnings


Given this code using boost 1.75 / gcc 11

#include <boost/bimap.hpp>
#include <string>
#include <iostream>

int main()
{
  typedef boost::bimap<std::string, int> bimap;
  bimap animals;

  animals.insert({"cat", 4});
  animals.insert({"shark", 0});
  animals.insert({"spider", 8});

  std::cout << animals.left.count("cat") << '\n';
  std::cout << animals.right.count(8) << '\n';
}

I get many warnings such as boost concept failed ...

More logs:

https://godbolt.org/z/6Ge5vxYrc

How to fix this if I do not have the ability to upgrade boost


Solution

  • As the messages suggest, you can suppress the -Wnonnull diagnostics:

    g++ -std=c++17 -Wno-nonnull ...
    

    https://godbolt.org/z/YEafWTqex