fork download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5. template <typename... Types>
  6. class Test
  7. {
  8. public:
  9. template <typename... Ts>
  10. void Func(Ts...)
  11. {
  12. static_assert(sizeof...(Ts) == sizeof...(Types), "");
  13. static_assert(std::conjunction<std::is_same<Ts, int>...>{}, "");
  14. }
  15. };
  16.  
  17.  
  18. int main() {
  19. Test<string, bool, long> myTest; // Three types
  20. myTest.Func(905, 36, 123315); // Three arguments, but always of type int.
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 3468KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function 'void Test<Types>::Func(Ts ...)':
prog.cpp:13:23: error: 'conjunction' is not a member of 'std'
         static_assert(std::conjunction<std::is_same<Ts, int>...>{}, "");
                       ^
prog.cpp:13:61: error: expected primary-expression before '...' token
         static_assert(std::conjunction<std::is_same<Ts, int>...>{}, "");
                                                             ^
prog.cpp:13:61: error: expected ',' before '...' token
prog.cpp:13:61: error: expected string-literal before '...' token
prog.cpp:13:61: error: expected ')' before '...' token
stdout
Standard output is empty