fork(3) download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. bool is_one_of(T const value, T const value1, T const ... values) {
  5. return value == value1 || is_one_of(value, values);
  6. }
  7.  
  8. template<typename T>
  9. bool is_one_of(T const value, T const value1) {
  10. return value == value1;
  11. }
  12.  
  13. int main() {
  14. std::cout << is_one_of<int>(1, 2);
  15. }
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:59: error: expansion pattern ‘const T’ contains no argument packs
 bool is_one_of(T const value, T const value1, T const ... values) {
                                                           ^~~~~~
prog.cpp: In function ‘bool is_one_of(T, T)’:
prog.cpp:5:48: error: ‘values’ was not declared in this scope
     return value == value1 || is_one_of(value, values);
                                                ^~~~~~
prog.cpp:5:48: note: suggested alternative: ‘value’
     return value == value1 || is_one_of(value, values);
                                                ^~~~~~
                                                value
prog.cpp: At global scope:
prog.cpp:9:6: error: redefinition of ‘template<class T> bool is_one_of(T, T)’
 bool is_one_of(T const value, T const value1) {
      ^~~~~~~~~
prog.cpp:4:6: note: ‘template<class T> bool is_one_of(T, T)’ previously declared here
 bool is_one_of(T const value, T const value1, T const ... values) {
      ^~~~~~~~~
stdout
Standard output is empty