小编baa*_*rdk的帖子

C++ 0x中std :: make_tuple的问题

为了使用Visual Studio 10编译以下程序,我得到了很多编译错误:

#include "stdafx.h"

#include <tuple>
#include <string>
#include <map>
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    typedef std::tuple<std::string, std::string> key_t;
    typedef std::map<key_t, std::string> map_t;

    map_t the_map;

    auto k = std::make_tuple("one", "two");
    the_map[k] = "the value";

    auto  q = std::make_tuple("one", "two");

    auto  i = the_map.find(q);
    std::cout << i->second << std::endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

错误1错误C2664:'std :: basic_string <_Elem,_Traits,_Ax> :: basic_string(const std :: basic_string <_Elem,_Traits,_Ax>&)':无法将参数1从'const key_t'转换为'const std :: basic_string <_Elem,_Traits,_Ax>&'c:\ program files(x86)\ microsoft visual studio 10.0\vc\include\tuple 127 1 tuple

来自这条线: …

c++ visual-studio-2010 c++11

5
推荐指数
1
解决办法
3455
查看次数

标签 统计

c++ ×1

c++11 ×1

visual-studio-2010 ×1