fork download
  1. #include <tuple>
  2. #include <iostream>
  3.  
  4. template <typename... T>
  5. void my_real_func(T&&... args)
  6. {
  7. bool foo[] = { std::cout << args << ' '... };
  8. }
  9.  
  10. template <int... i, typename... T>
  11. void func(T&&... args)
  12. {
  13. using tuple_type = std::tuple<T&&...>;
  14. tuple_type arg_tuple( std::forward<T>( args )... );
  15. my_real_func( std::forward<typename std::tuple_element<i-1, tuple_type>::type>( std::get<i-1>( arg_tuple ) )... );
  16. }
  17.  
  18. int main()
  19. {
  20. func<1, 2, 3>( 2, 3, 5 ); std::cout << '\n';
  21. func<2, 1, 3>( 2, 3, 5 ); std::cout << '\n';
  22. func<2, 2, 2>( 2, 3, 5 ); std::cout << '\n';
  23. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
2 3 5 
3 2 5 
3 3 3