I'm getting error from the compiler when coding C++. Here is my code:
#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;
}
and here is my error:
Any idea what is causing this?
I'm using Codeblocks 12.11, Windows 7 and my compiler is GNU GCC Compiler
Thnx for the assist :)
UPDATE:
In case somebody bumps into the same problem, here is the solution (in Codeblocks 12.11):
Go to: Settings --> Compiler --> Compiler settings --> Check the following checkboxes:
In addition to that remember to have a main
-function in your code. Otherwise the compiler will give the following error:
The solution was given by the users who answered my post :)
Your compiler is not supporting C++11. The emplace_back
member function of std::vector<T>
has been added since C++11, as you can see.
Depending on your compiler version, you probably just need some flags to tell the compiler to turn on C++11 features. You can do that on GCC and Clang with:
-std=c++11 -stdlib=libc++
Otherwise you might need to update your compiler version to a more recent one.