dimanche 6 décembre 2015

std::error_code assignment operator not found

The following code generates a C2679 compiler error saying: binary '=' : no operator found which takes a right-hand operand of type 'std::errc' (or there is no acceptable conversion).

#include <system_error>
int main(int argc, char *argv[])
{
  static_assert(std::is_error_code_enum<decltype(std::errc::address_family_not_supported)>::value,"It should work");
  std::error_code ec;
  ec = std::errc::address_family_not_supported;
  return 0;
}

According to the documentation there should be such an operator, if the enum has the template specialization std::is_error_code_enum. And I do get back "It should work" from the compiler. Compiler bug?

Using VS2013.

Aucun commentaire:

Enregistrer un commentaire