目的是std::make_pair什么?
为什么不std::pair<int, char>(0, 'a')呢?
这两种方法有什么区别吗?
我正在使用启用了-std = c ++ 11的g ++ 4.7(后面的一个快照).我试图编译一些现有的代码库,一个失败的案例让我感到困惑.
如果有人能解释发生了什么,我将不胜感激.
这是代码
#include <utility>
#include <iostream>
#include <vector>
#include <string>
int main ( )
{
std::string s = "abc";
// 1 ok
std::pair < std::string, int > a = std::make_pair ( s, 7 );
// 2 error on the next line
std::pair < std::string, int > b = std::make_pair < std::string, int > ( s, 7 );
// 3 ok
std::pair < std::string, int > d = std::pair < std::string, int > ( …Run Code Online (Sandbox Code Playgroud)