Hi,
I use MS Visual Studio 2015 and am trying to generate an error condition with value
std::errc::invalid_argument
. According to the header file
system_error
, there is a conditional constructor for
std::error_condition
for cases where the first argument satisfies
std::is_error_condition_enum
.
When such a trait is satisfied (which is satisfied for
std::errc::invalid_argument
, then the said constructor should be available and the following code SHOULD compile:
1 2
|
auto econd = std::errc::invalid_argument;
std::error_condition ec(econd, std::system_category());
|
BUT, alas, it does not! The declaration for this constructor is:
1 2
|
template<class _Enum, class = typename enable_if<is_error_condition_enum<_Enum>::value, void>::type>
error_condition::error_condition(_Enum _Errcode){...}
|
For some reason, this constructor becomes available but there is still a mismatch for the first argument and I believe there is something wrong with this declaration.
I played with a similar case on a class of mine and got it to work with the following constructor:
template<class _Enum, typename std::enable_if<std::is_error_condition_enum<_Enum>::value>::type* = nullptr>
What could be wrong with the provided declaration and IF indeed wrong, HOW can we correct it??? (Modifying the header file seems NOT a good policy since it is a system header...)
Thanks,
Juan