Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the reason for `std::result_of` deprecated in C++17?

Tags:

I saw std::result_of is being deprecated in C++17.

  • What is the reason for std::result_of deprecated in C++17?
  • Also I would like to know the difference between std::result_of and std::invoke_result.
like image 659
msc Avatar asked Sep 03 '17 08:09

msc


People also ask

What is deprecated in C ++ 17?

Along with the new features added to the language and the standard library in C++17, there are also existing features that have been either removed (after being deprecated in a previous version) or deprecated so they would be removed sometime in the future.

What are results C++?

Result<T, E> is a template type that can be used to return and propage errors. It can be used to replace exceptions in context where they are not allowed or too slow to be used.


1 Answers

T.C. already provided the obvious link, but perhaps the most horrific reason bears repeating: result_of involved forming the type F(Arg1, Arg2, ...) not for a function of those types returning F but for a function of type F accepting those types. (After all, the return type is the result of, well, result_of, not the input!)

Aside from the adjustments associated with forming the function type, the only difference between the two is syntactic.

like image 144
Davis Herring Avatar answered Feb 10 '23 17:02

Davis Herring