I added a
main
function the above code vis:
#include <algorithm>
int main()
{
vector<node> test;
sort( test.begin(), test.end(), [](const node &a, const node &b){ return (a.distanceToStart < b.distanceToStart);});
}
This compiles without error using GCC, Clang and MSVC. Either you've managed to correct your lambda, or there is something else in your code that's causing problems. Maybe start by removing the
using namespace std;
directive and explicitly use the
std
namespace as needed.
If you're using separate compilation of your classes, then you should not be
using namespace std;
in the class header file. Doing so means that anything that does an
#include "myclass.hpp"
will also import all of the std namespace, which might cause unexpected results.