std::is_null_pointer(3)

πŸ“¦
version 2024.07.05 Β· 4 versions
, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ NAME πŸŽ€

hey bestie!! welcome to std::is_null_pointer(3) from the C++ Standard Libary πŸ’– (yes, that's the manual name, and yes we're obsessed). this page is literally about std::is_null_pointer, no cap.

  • std::is_null_pointer β€” std::is_null_pointer

✨ Synopsis ✨

Defined in header <type_traits>
template< class T >              (since C++14)
struct is_null_pointer;

std::is_null_pointer is a UnaryTypeTrait.

Checks whether T is the type std::nullptr_t.

Provides the member constant value that is equal to true, if T is the type std::nullptr_t, const std::nullptr_t, volatile std::nullptr_t, or const volatile std::nullptr_t.

Otherwise, value is equal to false.

🚨 bestie warning: if the program adds specializations for std::is_null_pointer or std::is_null_pointer_v (since C++17), the behavior is undefined. do not do that, fr fr.

🌸 Template parameters 🌸

  • T β€” a type to check

🧚 Helper variable template 🧚

this helper variable template is since C++17, iykyk:

template< class T >
inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value;

πŸ’« Inherited from std::integral_constant πŸ’«

inherited from std::integral_constant β€” that's the whole vibe.


πŸ’… Member constants πŸ’…

  • value [static] β€” true if T is the type std::nullptr_t (possibly cv-qualified), false otherwise (public static member constant)

πŸ¦‹ Member functions πŸ¦‹

  • operator bool β€” converts the object to bool, returns value (public member function)
  • operator() β€” returns value (C++14) (public member function)

🌈 Member types 🌈

  • value_type β€” bool
  • type β€” std::integral_constant<bool, value>

πŸ”₯ Possible implementation πŸ”₯

template<class T>
struct is_null_pointer : std::is_same<std::nullptr_t,
std::remove_cv_t<T>> {};

πŸ’€ Notes πŸ’€

std::is_pointer is false for std::nullptr_t because it is not a built-in pointer type.

Feature-test macro tea β˜•:

  • Feature-test macro β€” __cpp_lib_is_null_pointer
  • Value β€” 201309L
  • Std β€” (C++14)
  • Feature β€” std::is_null_pointer

πŸ“ Example πŸ“

// Run this code

#include <type_traits>

static_assert(std::is_null_pointer_v<decltype(nullptr)>);
static_assert(!std::is_null_pointer_v<int*>);
static_assert(!std::is_pointer_v<decltype(nullptr)>);
static_assert(std::is_pointer_v<int*>);

int main()
{
}

πŸ‘‘ See also πŸ‘‘

  • is_void (C++11) β€” checks if a type is void (class template)
  • is_array (C++11) β€” checks if a type is an array type (class template)
  • is_pointer (C++11) β€” checks if a type is a pointer type (class template)
  • is_enum (C++11) β€” checks if a type is an enumeration type (class template)
  • is_union (C++11) β€” checks if a type is a union type (class template)
  • is_class (C++11) β€” checks if a type is a non-union class type (class template)
  • is_function (C++11) β€” checks if a type is a function type (class template)
  • is_object (C++11) β€” checks if a type is an object type (class template)

kisses bestie πŸ’‹ β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::is_null_pointer(3). bye! 🫢

πŸ“¦ where this page comes from