std::array, ?
(: std:: array version, )
template< class... Args >
void f( Args&... args ) {
}
, ( ).
I = 0 Args..args f()
namespace Helper {
template< unsigned int N, unsigned int I >
struct Caller {
template< class T, class...Args >
static void call( const std::array<T,N>& arr, Args&... args ){
Caller<N,I-1>::call( arr, std::get<I-1>(arr), args... );
}
};
template < unsigned int N >
struct Caller<N, 0> {
template< class T, class...Args >
static void call( const std::array<T,N>& arr, Args&... args ) {
f(args...);
}
};
}
template< typename T, unsigned N >
void call_f( const std::array<T,N>& arr ){
Helper::Caller<N,N>::call(arr);
}
.
std::array<float,3> array = {4.3, 3.14,2.1} ;
call_f(array);