fork(1) download
  1. #include <array>
  2. #include <iostream>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T, size_t I>
  8. bool bar(const T& param) { return param[I] != 13; }
  9.  
  10. template <typename T, size_t... ARGS>
  11. void bar(const T& param, const std::index_sequence<ARGS...>&) {
  12. if(bar<ARGS>(param) && ...)
  13. {
  14. cout << "no matches\n";
  15. }
  16. else
  17. {
  18. cout << "matched\n";
  19. }
  20. }
  21.  
  22. int main() {
  23. const array<int, 3U> foo = { 0, 1, 2 };
  24.  
  25. bar(foo, std::make_index_sequence<std::size(decltype(foo)())>());
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void bar(const T&, std::index_sequence<ARGS ...>&)’:
prog.cpp:12:23: error: expected ‘)’ before ‘&&’ token
   if(bar<ARGS>(param) && ...)
                       ^~
prog.cpp:12:29: error: parameter packs not expanded with ‘...’:
   if(bar<ARGS>(param) && ...)
                             ^
prog.cpp:12:29: note:         ‘ARGS’
prog.cpp: In function ‘int main()’:
prog.cpp:25:37: error: ‘size’ is not a member of ‘std’
   bar(foo, std::make_index_sequence<std::size(decltype(foo)())>());
                                     ^~~
prog.cpp:25:37: error: ‘size’ is not a member of ‘std’
prog.cpp:25:63: error: template argument 1 is invalid
   bar(foo, std::make_index_sequence<std::size(decltype(foo)())>());
                                                               ^
stdout
Standard output is empty