1
0
Fork 0
modern_cpp_tutorial/chapters/chapter_02/src/null.cpp

30 lines
743 B
C++
Raw Normal View History

2023-10-18 17:49:49 +00:00
#include <iostream>
#include <type_traits>
#include "null.h"
void call_test(char *) { std::cout << "call_test(char *) called" << std::endl; }
void call_test(int) { std::cout << "call_test(int) called" << std::endl; }
2023-10-21 14:44:06 +00:00
void NullTest::run() {
2023-10-18 17:49:49 +00:00
if (std::is_same<decltype(NULL), decltype(0)>::value) {
std::cout << "NULL == 0" << std::endl;
}
if (std::is_same<decltype(NULL), decltype((void *)0)>::value) {
std::cout << "NULL == (void *)0" << std::endl;
}
if (std::is_same<decltype(NULL), decltype(__null)>::value) {
std::cout << "NULL == __null" << std::endl;
}
if (std::is_same<decltype(NULL), std::nullptr_t>::value) {
std::cout << "NULL == nullptr" << std::endl;
}
call_test(0);
call_test(nullptr);
}