Skip to content

Instantly share code, notes, and snippets.

@vsapsai
Last active January 22, 2017 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsapsai/438d879692a55ae9b559c61ef2c948a3 to your computer and use it in GitHub Desktop.
Save vsapsai/438d879692a55ae9b559c61ef2c948a3 to your computer and use it in GitHub Desktop.
Test case for include-what-you-use issue #384: Build fails after Clang r289250
template<typename T> class I1_const_ptr {
public:
explicit I1_const_ptr(const T* ptr) : ptr_(ptr) { }
// ~I1_const_ptr() { delete ptr_; }
const T& operator*() { return *ptr_; }
const T* operator->() { return ptr_; }
int operator~() { return deref_a(); }
void del() { delete (((ptr_))); }
void indirect_del() { del(); }
int deref_a() { return (*ptr_)->a(); }
private:
const T* ptr_;
};
// Try an out-of-line operator too, both regular-style and yoda-style.
template<typename T> bool operator==(I1_const_ptr<T>& ptr, const T& val) {
return &*ptr == &val;
}
template<typename T> bool operator==(const T& val, I1_const_ptr<T>& ptr) {
return &*ptr == &val;
}
class I1_Class {};
#include "const_ptr.h"
#include "i1_class.h"
class I1_Class;
void foo(I1_Class& i1_class) {
I1_const_ptr<I1_Class> local_i1_const_ptr(0);
(void)(local_i1_const_ptr == i1_class);
(void)(i1_class == local_i1_const_ptr);
}
void bar(I1_Class* ptr) {
(void)*ptr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment