Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::remove_pointer

      From cppreference.com
      <cpp‎ |types
       
       
      Metaprogramming library
      Type traits
      Type categories
      (C++11)
      (C++11)(DR*)
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      (C++11) 
      Type properties
      (C++11)
      (C++11)
      (C++14)
      (C++11)(deprecated in C++26)
      (C++11)(until C++20*)
      (C++11)(deprecated in C++20)
      (C++11)
      Type trait constants
      Metafunctions
      (C++17)
      Supported operations
      Relationships and property queries
      Type modifications
      Type transformations
      (C++11)(deprecated in C++23)
      (C++11)(deprecated in C++23)
      (C++11)
      (C++11)(until C++20*)(C++17)

      Compile-time rational arithmetic
      Compile-time integer sequences
       
      Defined in header<type_traits>
      template<class T>
      struct remove_pointer;
      (since C++11)

      Provides the member typedeftype which is the type pointed to byT, or, ifT is not a pointer, thentype is the same asT.

      If the program adds specializations forstd::remove_pointer, the behavior is undefined.

      Contents

      [edit]Member types

      Name Definition
      type the type pointed to byT orT if it's not a pointer

      [edit]Helper types

      template<class T>
      using remove_pointer_t=typename remove_pointer<T>::type;
      (since C++14)

      [edit]Possible implementation

      template<class T>struct remove_pointer{typedef T type;};template<class T>struct remove_pointer<T*>{typedef T type;};template<class T>struct remove_pointer<T*const>{typedef T type;};template<class T>struct remove_pointer<T*volatile>{typedef T type;};template<class T>struct remove_pointer<T*constvolatile>{typedef T type;};

      [edit]Example

      Run this code
      #include <type_traits> static_assert(std::is_same_v<int,int>==true&&std::is_same_v<int,int*>==false&&std::is_same_v<int,int**>==false&&std::is_same_v<int, std::remove_pointer_t<int>>==true&&std::is_same_v<int, std::remove_pointer_t<int*>>==true&&std::is_same_v<int, std::remove_pointer_t<int**>>==false&&std::is_same_v<int, std::remove_pointer_t<int*const>>==true&&std::is_same_v<int, std::remove_pointer_t<int*volatile>>==true&&std::is_same_v<int, std::remove_pointer_t<int*constvolatile>>==true); int main(){}

      [edit]See also

      (C++11)
      checks if a type is a pointer type
      (class template)[edit]
      adds a pointer to the given type
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/remove_pointer&oldid=152511"

      [8]ページ先頭

      ©2009-2025 Movatter.jp