[英]'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.