Compare map<string,any> c++ 17

Asked

Viewed 38 times

0

I can’t compare two maps .

Ex:

  map<string, any> columnsMap = {
      {"status", 1}, {"client_delivered", 0}, {"client_notification", 0}};
  map<string, any> columnsMap2 = {
      {"status", 1}, {"client_delivered", 0}, {"client_notification", 0}};
  if (columnsMap2 == columnsMap)
    std::cout << "algo" << std::endl;

Received message:

/usr/include/c++/9.3.0/bits/stl_pair.h:449:51: note:   ‘const std::any’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
[build]   449 |     { return __x.first == __y.first && __x.second == __y.second; }

Is there any way to make this direct comparison?

Looking at the Std::any documentation does not have the [Operator==] operator implemented

  • Have you researched Std:: ?

  • @Fourzerofive already, the solution I found was to use Std::Variant instead of any. It is not what I would like, but it is the most sensible.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.