vendredi 21 juillet 2017

Lambda with auto type within collection sorting argument

This is an example of a simplified problem that I try to resolve.

auto comp = [](int x, int y) {
    return x < y;
};

struct S {
    set<int, decltype(comp)> reads(comp);
};

I am using the following command to compile mine code:

g++ -std=c++14 -o test.exe test.cpp

Unfortunatelly it keeps producing following error:

test.cpp:32:65: error: unknown type name 'comp'
set<int, decltype(comp)> reads(comp);
                               ^

I have tried to install newer version of g++, but it doesn't work. I executed this command on MacOs with Clang, as well as Ubuntu 16 with g++ in version 5.2.

Aucun commentaire:

Enregistrer un commentaire