After understanding decltype
with 2 arguments I am wondering, could I just use that instead of enable_if
? For example:
template <typename T>
decltype(T(), declval<bool>()) isConstructable() { return true; }
Succeeds with isConstructable<int>
and fails with isConstructable<istream>
on Visual Studio 2015: http://rextester.com/YQI94257 But on gcc I have to do:
template <typename T>
enable_if_t<decltype(T(), true_type())::value, bool> isConstructable() { return true; }
Should the decltype
version work, or am I just exploiting a non-standard Microsoftianisim?