3

In C++, the "decay" of array->pointer and function->function pointer happens when we pass array/function name as parameter to function call argument. This is automatically done by compiler itself.

My question is why in C++11 the new language standard should introduce a template "decay" functor? I don't see obvious real-world usage of it, and the website(http://en.cppreference.com/w/cpp/types/decay) simply gives an snippet that this "decay" could help to detect if some types could be decay-ed into some other types, which I suppose not useful at all.

Would you kindly give some example?

Baum mit Augen
  • 47,658
  • 24
  • 139
  • 177
Hind Forsum
  • 8,897
  • 9
  • 50
  • 103
  • 5
    It's not a functor, afaik. It's used for template meta programming – Danh Feb 22 '17 at 06:37
  • It's not a functor in the C++ sense, which uses that word to mean function object. It is a functor in the category theory sense, i.e. a mapping from C++ types to C++ types – Caleth Feb 22 '19 at 13:05

0 Answers0