C ++编译器:&#39;类std :: vector <std :: vector <char>&gt;&#39;没有名为&#39; emplace_back&#39; </std :: vector <char>的成员

时间:2013-11-05 12:46:50

标签: c++ vector compiler-construction

编译C ++时,编译器出错了。这是我的代码:

#include <iostream>     
#include <algorithm>   
#include <typeinfo>
#include <string>
#include <vector>


std::vector< std::vector<char> > p(std::vector<char> v)
{
    std::vector< std::vector<char> > result;

    std::sort(v.begin(), v.end());
    do
    {
        result.emplace_back(v);
    }
    while(std::next_permutation(v.begin(), v.end()));

    return result;
}

这是我的错误:

enter image description here

知道造成这种情况的原因是什么?

我正在使用Codeblocks 12.11,Windows 7,我的编译器是GNU GCC Compiler

Thnx的助攻:)

更新

如果有人碰到同样的问题,这就是解决方案(在Codeblocks 12.11中):

转到:设置 - &gt;编译器 - &gt;编译器设置 - &gt;选中以下复选框:

enter image description here

除此之外,请记住在代码中使用main - 函数。否则编译器将给出以下错误:

enter image description here

解决方案是由回复我帖子的用户发出的:)

1 个答案:

答案 0 :(得分:10)

您的编译器不支持C ++ 11。 {C} 11之后添加了emplace_back std::vector<T>成员函数,you can see

根据您的编译器版本,您可能只需要一些标志来告诉编译器打开C ++ 11的功能。你可以用GCC和Clang做到这一点:

-std=c++11 -stdlib=libc++

否则,您可能需要将编译器版本更新为更新版本。

相关问题