C编译器:’class std :: vector>’没有名为’emplace_back’的成员

前端之家收集整理的这篇文章主要介绍了C编译器:’class std :: vector>’没有名为’emplace_back’的成员前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在编写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;
}

这是我的错误

知道是什么导致了这个吗?

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

Thnx的助攻:)

更新:

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

转到:设置 – >编译器 – >编译器设置 – >选中以下复选框:

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

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

解决方法

您的编译器不支持C 11. std :: vector< T>的emplace_back成员函数.自C 11以来已被添加you can see.

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

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

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

原文链接:https://www.f2er.com/c/119741.html

猜你在找的C&C++相关文章