简体   繁体   English

&#39;class std :: map <std::basic_string<char> ,Gui&gt;&#39;没有名为&#39;emplace&#39;的成员

[英]'class std::map<std::basic_string<char>, Gui>' has no member named 'emplace'

Hi Guy's looking for some help and can't understand the problem. 嗨,Guy正在寻求帮助,无法理解问题。 I'm following this tutorial https://www.binpress.com/tutorial/creating-a-city-building-game-with-sfml-part-8-gui-system/130 , I'm using CodeBlocks 13.12 and SFML 2.1 but when I try to compile the code I get this 我正在关注本教程https://www.binpress.com/tutorial/creating-a-city-building-game-with-sfml-part-8-gui-system/130 ,我正在使用CodeBlocks 13.12和SFML 2.1但是当我尝试编译代码时,我得到了

||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|
C:\Users\James\Desktop\Summer Repeats 2015\Games Dev 2\Test\src\Game_State_Start.cpp||In constructor 'GameStateStart::GameStateStart(Game*)':|
C:\Users\James\Desktop\Summer Repeats 2015\Games Dev 2\Test\src\Game_State_Start.cpp|100|error: 'class std::map<std::basic_string<char>, Gui>' has no member named 'emplace'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

This is the line of code giving me this error. 这是给我这个错误的代码行。

this->guiSystem.emplace("menu", Gui(sf::Vector2f(192, 32), 4, false, game->stylesheets.at("button"),
    { std::make_pair("Load Game", "load_game") }));

I have CodeBlocks set for C++11 and change SFML to SFML-2.3.1-windows-gcc-4.9.2-mingw-32-bit because I found here saying I have to use g++ 4.8.0 or higher on this page std::map emplace gcc 4.8.2 , but still getting the same error, also the website give's me the code to download even though I'm trying to follow it myself , I checked the code, importing into a new project and that didn't work either, So no idea whats wrong. 我为C ++ 11设置了代码块,并将SFML更改为SFML-2.3.1-windows-gcc-4.9.2-mingw-32位,因为我在这里说我必须在此页面上使用g ++ 4.8.0或更高版本std :: map emplace gcc 4.8.2 ,但仍然出现相同的错误,即使我自己尝试遵循该网站,该网站也为我提供了下载代码,我检查了代码,导入了一个新项目,但是也不起作用,所以不知道怎么了。 Any help or a point in the right direction would be most appreciated. 如有任何帮助或朝着正确方向的观点,将不胜感激。

Normally I would post this in a comment but I don't have enough rep. 通常,我会在评论中发布此信息,但我没有足够的代表。
Start a new project and compile and run this code: 启动一个新项目并编译并运行以下代码:

#include <iostream>
#include <ostream>

int main()
{
    std::cout << __cplusplus << std::endl;
}

If the result printed out is 199711 , then it means you're not compiling using the -std=c++11 option. 如果打印出的结果是199711 ,则意味着您不使用-std=c++11选项进行编译。 If the result printed out is 201101 then it means you're using an outdated version of the standard library. 如果打印出的结果是201101则表明您使用的是标准库的过时版本。

Found the solution. 找到了解决方案。 I had originally installed codeblocks-13.12mingw-setup, I uninstalled this and installed codeblocks-13.12mingw-setup-TDM-GCC-481. 我最初安装了codeblocks-13.12mingw-setup,然后我卸载了它并安装了codeblocks-13.12mingw-setup-TDM-GCC-481。 It works now. 现在可以使用了。 Thanks for everybody's help. 感谢大家的帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 的std ::矢量 <std::basic_string<char> &gt; :: const_iterator&#39;没有名为&#39;c_str&#39;的成员 - std::vector<std::basic_string<char> >::const_iterator’ has no member named ‘c_str’ cpp:错误:'类提升::可选<std::__cxx11::basic_string<char> &gt;' 没有名为 'c_str' 的成员</std::__cxx11::basic_string<char> - cpp: error: 'class boost::optional<std::__cxx11::basic_string<char> >' has no member named 'c_str' C ++编译器:'class std :: vector <std :: vector <char >>>'没有名为'emplace_back'的成员 - C++ compiler: 'class std::vector<std::vector<char> >' has no member named 'emplace_back' 转换 std::basic_string<Char> 串起来 - Convert std::basic_string<Char> to string std :: string {aka std :: basic_string <char> 分配给&#39;&#39;&#39;char *&#39; - std::string {aka std::basic_string<char>}' to 'char*' in assignment| 错误:没有匹配的函数调用&#39;std :: map <std::__cxx11::basic_string<char> - error: no matching function for call to ‘std::map<std::__cxx11::basic_string<char> 无法从&#39;const std :: __ 1 :: basic_string转换 <char> 到&#39;std :: __ 1 :: basic_string <char> *” - No viable conversion from 'const std::__1::basic_string<char> to 'std::__1::basic_string<char> *' 错误:无法从&#39;std :: string * {aka std :: basic_string转换 <char> *}&#39;为&#39;std :: string {aka std :: basic_string <char> }&#39;| - error: could not convert from 'std::string* {aka std::basic_string<char>*}' to 'std::string {aka std::basic_string<char>}'| C++“错误:传递&#39;const std::map <int, std::basic_string<char> &gt;&#39; 作为 &#39;this&#39; 的论点...&quot; - C++ "error: passing 'const std::map<int, std::basic_string<char> >' as 'this' argument of ..." 从std :: map转换 <std::basic_string<char> ,std :: pair - conversion from std::map<std::basic_string<char>,std::pair<int,int(*)(const std::vector::Mat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM