abraham_hilbert - 7 months ago 46

C++ Question

I have the following problem:

`template< typename callable, typename T , size_t... N_i>`

void foo()

{

using callable_out_type = std::result_of_t< callable( /* T , ... , T <- sizeof...(N_i) many */ ) >;

// ...

}

I want to get the result type of

`callable`

`sizeof...(N_i)`

`T`

`callable(1,2,3)`

`T==int`

`sizeof...(N_i)==3`

Many thanks in advance.

Answer

Why not simply use:

```
using callable_out_type = std::result_of_t< callable( decltype(N_i, std::declval<T>())...) >;
```

Source (Stackoverflow)