I made a template and an auto function that compare 2 values and return the smallest one. This is my code:
#include
Until yesterday (2017-12-06) this was not compiling under MSVC. But after VS 15.5 update it does.
auto msvc_does_compile = [](auto _string)
{
using string_type = decltype(_string);
return std::vector{};
};
/*
OK since VS 2017 15.5 update
auto vec1 = msvc_does_compile( std::string{} );
*/
Adding explicit return type will choke MSVC , but not gcc/clang as usual:
auto msvc_does_not_compile = [](auto _string)
// explicit return type makes msvc not to compile
-> std::vector< decltype(_string) >
{
using string_type = decltype(_string);
return std::vector{};
};
And something of the same but simpler will be stopped even at the IDE stage:
auto msvc_ide_does_not_allow = []( bool wide )
{
if (wide)
return std::vector();
return std::vector();
};
Yes, again that troublesome pair gcc/clang has no problems with the above. Try which ever online ide you prefer to convince yourself...