2 ENABLE_IF: ONE WORKS THE OTHER DOES NOT???

Hi,

I have 2 enable_ifs... the first DOES NOT WORK, the second DOES!! Why??

-------- FIRST enable_if constructor for dummy class error_player-------
template<class _Enum, class = typename std::enable_if<std::is_error_condition_enum<_Enum>::value,void>::type>
error_player(_Enum _Errcode) _NOEXCEPT
{ // construct from enumerated error code
}

-------- SECOND enable_if constructor for dummy class error_player-------
template<class _Enum, typename std::enable_if<std::is_error_condition_enum<_Enum>::value>::type* = nullptr>
error_player(_Enum _Errcode) _NOEXCEPT

{ // construct from enumerated error code
}
--------------------

I took the first one from the declaration of the ctor for error_condition, which isn't working for me and is as follows:

template<class _Enum,
class = typename enable_if<is_error_condition_enum<_Enum>::value,
void>::type>
error_condition(_Enum _Errcode) _NOEXCEPT
: _Myval(0), _Mycat(0)
{ // construct from enumerated error code
*this = make_error_condition(_Errcode); // using ADL
}
This is using MS Visual Studio 2015...

When I try to use code to create an object from error_player or from error_condition, like so:

error_player eep( std::errc::invalid_argument );

std::error_condition ec( std::errc::invalid_argument, std::system_category() );

I get no instance matches the argument list...

And this is though the following test verifies that the passed in value IS an error_condition_enum as verified with:

if (std::is_error_condition_enum<decltype(std::errc::invalid_argument)>::value) {
std::cout << "is error condition enum\n";
}
------------

Any ideas?

Thanks
Juan
Hi Juan,

First up, I think you ask some good questions :+)

However I wonder if we could ask you to use code tags always, even for the small code fragments.

The scope of your questions is quite often beyond my ability to provide an answer, but it would be nice (for others too) if your question was a little more readable.

http://www.cplusplus.com/articles/z13hAqkS/

Regards & Cheers
Thanks --- will rephrase this question!!
Topic archived. No new replies allowed.