• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main() {
    5.  
    6. // nullptr が使えるようになった。
    7. int *ptr = nullptr;
    8.  
    9. // if文で直接判断可能
    10. if (ptr) {
    11. cout << "ptr!" << endl;
    12. } else {
    13. cout << "no ptr" << endl;
    14. }
    15.  
    16. // もちろん nullptr と比較しても可
    17. if (ptr != nullptr) {
    18. cout << "ptr!" << endl;
    19. } else {
    20. cout << "no ptr" << endl;
    21. }
    22.  
    23. return 0;
    24. }