fork(1) download
  1. #include <vector>
  2. #include <set>
  3. #include <typeinfo>
  4. #include <cassert>
  5. #include <algorithm>
  6.  
  7. #define RANGE(x) (x).begin(), (x).end()
  8.  
  9. template<class T>
  10. struct is_STL_container
  11. {
  12. static const bool value = false;
  13. };
  14.  
  15. template<class T, typename alloc>
  16. struct is_STL_container<std::vector<T, alloc>>
  17. {
  18. static const bool value = true;
  19. };
  20.  
  21. template<class T, class comp, typename alloc>
  22. struct is_STL_container<std::set<T, comp, alloc>>
  23. {
  24. static const bool value = true;
  25. };
  26.  
  27.  
  28. template <class T1, class T2,
  29. class = std::enable_if_t<is_STL_container<T1>::value &&
  30. is_STL_container<T2>::value>::value>
  31. T1 operator - (const T1 &l, const T2 &r)
  32. {
  33. assert(typeid(typename T1::value_type) == typeid(typename T2::value_type));
  34.  
  35. std::vector<typename T1::value_type> result;
  36. std::set_difference(RANGE(l), RANGE(r), std::back_inserter(result));
  37. return T1(RANGE(result));
  38. }
  39.  
  40. int main() {
  41. // your code goes here
  42. return 0;
  43. }
Compilation error #stdin compilation error #stdout 0s 3452KB
stdin
Standard input is empty
compilation info
prog.cpp:29:11: error: need 'typename' before 'std::enable_if_t<(is_STL_container<T>::value && is_STL_container<T2>::value)>::value' because 'std::enable_if_t<(is_STL_container<T>::value && is_STL_container<T2>::value)>' is a dependent scope
   class = std::enable_if_t<is_STL_container<T1>::value &&
           ^
stdout
Standard output is empty