What does `struct decay <T, R (A ..., ...)>` mean?

template <typename T, typename R, typename ...A>
struct decay<T, R(A..., ...)> { using type = R(*)(A..., ...); };

What is the exact value? I need help ~

+6
source share
2 answers
int foo(int);
int bar(int, ...);

these are two different functions. foohas type int(int). barhas type int(int,...).

...is C-style varargs so as not to be confused with the arguments of the variational pattern that they also use ....

template <typename T, typename R, typename ...A>
struct decay<T, R(A..., ...)> { using type = R(*)(A..., ...); };

This part of the implementation of the optimized version is std::decayinside boost::hana. Parts typename Tand Tare red herrings, part of this optimization.

This specialization, which corresponds to R(A..., ...), where A...and Rare derived from the signature of the function.

double(int, char, ...) hana::details::decay, R double, A... int, char. ... " C".

, , varargs C-, . double(int, char, ...) double(*)(int, char, ...).

C . .

+7

, , , lvalues ​​, printerues .

(, , , - ).

+6

Source: https://habr.com/ru/post/1016074/


All Articles