c++ - Proper way to use SFINAE struct defintions -


for educative reasons, playing around sfinae behavior of c++ , building own version of std::enable_if in rather simplified form. noticed different behavior when using different implementation details though:

implementation incomplete type:

template <bool c, typename> struct enable_if; // incomplete type template <typename t> struct enable_if<true, t> { typedef t type; }; 

implementation empty type:

template <bool c, typename> struct enable_if {}; // empty type template <typename t> struct enable_if<true, t> { typedef t type; }; 

on g++ (4.8.1 , 4.3.2) both versions compile , behave same way. msvc 2008 seems accept definition empty type.

are both definitions valid c++, , should equivalent in behavior?

from standard, § 14.8.2:

type deduction may fail following reasons: [...] attempting use type in nested-name-specifier of qualified-id when type not contain specified member, or specified member not type type required [...]

both cases handled in same sentence, understanding should not make difference - both implementations should equivalent.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -