Created
November 1, 2016 15:48
-
-
Save Bueddl/946daf4f1aef05c53f37e0b748e14759 to your computer and use it in GitHub Desktop.
save nullptr
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 my_nullptr_t | |
{ | |
public: | |
template<class T> | |
operator T*() const noexcept | |
{ | |
return reinterpret_cast<T*>(0); | |
} | |
} my_nullptr; | |
class Dummy | |
{ | |
}; | |
int main() | |
{ | |
auto dummy = new Dummy; | |
if (dummy == my_nullptr) | |
{ | |
// is null | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment