STL algorithm "equal()" not working in CodeBlocks

Hi everyone
I was recently trying to run a piece of code, after spending some time I compiled that code on online IDE and that worked. The error was due to STL algorithm equal here’s the code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
    vector<int> v1{ 2, 7, 1, 2, -2, 4, 0 };
    vector<int> v2{ 1, 23, 45, 1, 2, 4, 0 };
    bool same = equal(begin(v1), end(v1), begin(v2), end(v2));
    cout << same << endl;
    return 0;

Like this to_string() also not working, related question.

I am using -std=c++11 flag in compiler settings(also tried removing it). GCC version is 6.(something).
I don’t know what’s the reason behind this, but it will be great if someone can help.

Looking at cpp reference here, it says that std::equal (ver 5, with 4 iterators) only works for C++14 and beyond. Try using -std=c++14 flag instead.


Thanks, @hikarico, that was helpful.

1 Like