1

I am trying to use boost::container::map. During inserting data, the error "insert is ambiguous" is shown.

#include <boost/container/map.hpp>
#include <string>
#include <iostream>

int main()
{
  boost::container::map<std::string, int> map;
  map.insert("Ram",0);
}
Nastaran Hakimi
  • 695
  • 1
  • 16
  • 36
ram kumar
  • 13
  • 2
  • 5
    please include the error message, it should contain information on the two (or more) overloads that are candidates – 463035818_is_not_an_ai Oct 01 '19 at 11:27
  • 3
    Cannot reproduce: [I get *no match* for the call](https://godbolt.org/z/z1Dpov). What compiler and boost version are you using? – walnut Oct 01 '19 at 11:34
  • 1
    I get the same error as @uneven_mark, it works if i `std::make_pair(std::string("RAM"), 0));` though. – Borgleader Oct 01 '19 at 11:36
  • Possible duplicate of [insert to boost unordered map](https://stackoverflow.com/questions/15833847/insert-to-boost-unordered-map) – Mike van Dyke Oct 01 '19 at 12:05

1 Answers1

3

Your style of inserting is not correct. I provide the code:

#include <boost/container/map.hpp>
#include <string>
#include <iostream>
#include <ostream>

int main()
{
  boost::container::map<std::string, int> map;
  map.insert(std::pair<const std::string, int>("Ram",1));
  std::cout<< map["Ram"];
  return 0;
}
Nastaran Hakimi
  • 695
  • 1
  • 16
  • 36