fork download
  1. #include <type_traits>
  2. #include <vector>
  3.  
  4. template <typename T>
  5. struct ReadOnlyIterator
  6. {
  7. template <typename Container>
  8. typename std::enable_if<std::is_same<T, typename Container::value_type>::value, ReadOnlyIterator<T>&>::type operator= (const Container &v) { return *this; }
  9. };
  10.  
  11. int main()
  12. {
  13. ReadOnlyIterator<int> i;
  14. std::vector<int> v;
  15. std::vector<short> w;
  16. i = v;
  17. //i = w; //uncomment for error
  18. }
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty