• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    class template
    <type_traits>

    std::is_null_pointer

    namespace std {
      template <class T>
      struct is_null_pointer;
    
      template <class T>
      inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value; // C++17
    }
    

    概要

    Tnullptr_tか調べる

    効果

    is_null_pointerは、型Tnullptr_tであればtrue_typeから派生し、そうでなければfalse_typeから派生する。

    #include <type_traits>
    
    static_assert(std::is_null_pointer<std::nullptr_t>::value == true,
                  "value == true, nullptr_t is nullptr type");
    static_assert(std::is_same<std::is_null_pointer<std::nullptr_t>::value_type, bool>::value,
                  "value_type == bool");
    static_assert(std::is_same<std::is_null_pointer<std::nullptr_t>::type, std::true_type>::value,
                  "type == true_type");
    static_assert(std::is_null_pointer<std::nullptr_t>() == true,
                  "is_null_pointer<nullptr_t>() == true");
    
    static_assert(std::is_null_pointer<const std::nullptr_t>::value == true,
                  "value == false, const nullptr_t is nullptr type");
    
    static_assert(std::is_null_pointer<int>::value == false,
                  "value == false, int isn't nullptr type");
    
    int main(){}
    

    出力

    バージョン

    言語

    • C++14

    処理系

    参照