Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1.  
  2. template<typename T1, typename T2>
  3. struct TypeCompare { static const bool equal = false; };
  4. template<typename T>
  5. struct TypeCompare<T,T>{static const bool equal=true;};
  6.   template<typename Q=T> //unnecessary template parameter that will trick resolution rules and let the 0 case happen
  7.   void erase(const Q* ptr) {
  8.     TypeCompare<T,Q> checker;
  9.     static_assert(checker.equal,"Undefined behavior, you can only use the type of container for iterators!");
  10.     argue(ptr >= begin() && ptr < end(), "incorrect iterator");
  11.     erase_range<T>(&ptr, ptr + 1, end());
  12.     size = size - 1;
  13.   }
  14.  
  15. doing erase<T*>.(0) would still give me ambiguous case
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement