Skip to content

Instantly share code, notes, and snippets.

@Bueddl
Created November 1, 2016 15:48
Show Gist options
  • Save Bueddl/946daf4f1aef05c53f37e0b748e14759 to your computer and use it in GitHub Desktop.
Save Bueddl/946daf4f1aef05c53f37e0b748e14759 to your computer and use it in GitHub Desktop.
save nullptr
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