VS - lambda function - IntelliSense spinnt?



  • Hallo,

    ich will die Elemente eines vectors sortieren. Dafür nehme ich std::sort , wobei ich als drittes Argument eine lambda function benutzen will. Das Ganze kompiliert, IntelliSense meckert jedoch. Mache ich irgendetwas falsch, oder spinnt die IntelliSense?

    #include <algorithm>
    #include <string>
    #include <vector>
    
    struct nuke
    {
    	std::string name;
    	double      duration;
    	unsigned    dmg;
    };
    
    int main()
    {
    	nuke normal = { "pyre", 3.0, 4367 };
    	nuke aoe    = { "ve",  1.54, 1402 };
    
    	std::vector<nuke> nukes;
    	nukes.push_back( normal );
    	nukes.push_back( aoe );
    
    	/*
    		1 Error:
    			IntelliSense: more than one conversion function from "lambda []bool (const nuke &lhs, const nuke &rhs)->bool" to "<error-type>" applies:
                function "lambda []bool (const nuke &lhs, const nuke &rhs)->bool::operator bool (*)(const nuke &lhs, const nuke &rhs)() const"
                function "lambda []bool (const nuke &lhs, const nuke &rhs)->bool::operator bool (*)(const nuke &lhs, const nuke &rhs)() const"
                function "lambda []bool (const nuke &lhs, const nuke &rhs)->bool::operator bool (*)(const nuke &lhs, const nuke &rhs)() const"
    	*/
    	std::sort( begin(nukes), end(nukes), []( const nuke& lhs, const nuke& rhs ){ return lhs.dmg > rhs.dmg; } );
    }
    

    Danke euch. 🙂



  • out schrieb:

    Das Ganze kompiliert

    Damit ist die Antwort doch eigentlich schon gegeben, oder?



  • manni66 schrieb:

    out schrieb:

    Das Ganze kompiliert

    Damit ist die Antwort doch eigentlich schon gegeben, oder?

    joa, eingetlich schon, kann ich die IntelliSense trotzdem irgendwie ruhig stellen?



  • out schrieb:

    kann ich die IntelliSense trotzdem irgendwie ruhig stellen?

    Mit Visual Assist X 😉

    Nein, solche Tools haben eben teilweise ihre Probleme. Du kannst versuchen, die .sdf-Datenbankdatei zu löschen...


Anmelden zum Antworten