fork(1) download
  1. #include <list>
  2. #include <vector>
  3.  
  4. template<typename Iterator>
  5. void foo(Iterator begin, Iterator end)
  6. {
  7. static_assert(std::is_same<int, typename std::iterator_traits<Iterator>::value_type>::value,
  8. "Invalid value type : must be int");
  9. }
  10.  
  11. int main() {
  12. std::list<int> l1;
  13. std::vector<int> v1;
  14.  
  15. foo(std::begin(l1), std::end(l1)); // OK
  16. foo(std::begin(v1), std::end(v1)); // OK
  17.  
  18. int arr[10];
  19. foo(std::begin(arr), std::end(arr)); // OK
  20.  
  21. std::vector<float> v2;
  22. //foo(std::begin(v2), std::end(v2)); // Doesn't compile
  23. }
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty