Last active
January 22, 2017 07:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class I1_Class {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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