Below is code through error as std::bad_alloc. I am getting error on line obj_[key[i]] = value[i]; . please help me to fix it .
 #include<iostream>
 #include<map>
  using namespace std;
 namespace {
         const std::string key1 = "s1";
         const std::string key2 = "s2";
         const std::string value1 = "v1";
         const std::string value2= "v2";
 }
 int main()
 {
         std::string key[3] = {
                 key1, key2};
          std::string value[3] = {
                  value1,value2 };
         std::map<std::string,std::string> obj_;
         for (size_t i = 0; i < sizeof(key); ++i) { // here its thow std::bad_alloc
                 obj_[key[i]] = value[i];
            }
}
 
     
     
     
    