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
  • 49,044
  • 25
  • 144
  • 182
Hind Forsum
  • 9,717
  • 13
  • 63
  • 119
  • 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