Error compiling std::make_pair

Error compiling std::make_pair

Hi Folks,

This code fair to compile with -std=c++11 but compiles fine without the -std=c++11 switch.

#include <string>
#include <iostream>
#include <utility>
int main(int argc, char* argv[])
{
  std::pair<int, std::string> apair=std::make_pair <int, std::string> ( 66, "sixty-six" );
}

error:/home/michael/programming/compilers/intel/bin/icpc -std=c++11 tt.cpp
tt.cpp(6): error: no instance of function template "std::make_pair" matches the argument list
            argument types are: (int, const char [10])
    std::pair<int, std::string> apair=std::make_pair <int, std::string> ( 66, "sixty-six" );

/home/michael/programming/compilers/intel/bin/icpc -v
icpc version 14.0.0 (gcc version 4.8.0 compatibility)

g++ --version                                                                                                                  
g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)        

This is on Fedora 19 X64

Enjoy

michael

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I got the same complaint, regardless of -std=c++11, with several versions of g++,  I think icpc is more strict about matching std::string against const char[], without an appropriate cast.  Earlier versions of icpc don't get along at all with the latest g++.

It might be interesting to see whether is_convertible shows the same differences between g++ and icpc.  But I don't have such a personal interest in language lawyering, in case that's what you mean by "Enjoy!".

well Im definitly not a language lawyer but..

the code in the message above compiles with clang 3.3, clang trunk and g++ on fedora and msvc 2012 on windows.

Also this small variant compiles fine with icpc in c++11 mode

#include <string>
#include <iostream>
#include <utility>
int main(int argc, char* argv[])
{
  std::string s("sixty six");
  std::pair<int, std::string> apair=std::make_pair <int, std::string> ( 66, s.c_str() );
}

michael

I tried your test case with the newest 14.0 compiler which I could find (14.0.4) and it compiles ok with or without the -std=c++11, looks like that problem was fixed.  We're currently shipping 16.0

That's correct Melanie. I tried with the next 14.0 version (update release) and it works fine. 

@Michael:  If you can upgrade to the latest 16.0 release (Initial Release) that'll be nice since a lot of new features/bug fixes etc., has gone into the newer release as well...

_Kittur

Leave a Comment

Please sign in to add a comment. Not a member? Join today