Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::is_final

      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)
      is_final
      (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 is_final;
      (since C++14)

      std::is_final is aUnaryTypeTrait.

      IfT is afinal class, provides the member constantvalue equaltrue. For any other type,value isfalse.

      IfT is an incomplete class type, the behavior is undefined.

      If the program adds specializations forstd::is_final orstd::is_final_v(since C++17), the behavior is undefined.

      Contents

      [edit]Template parameters

      T - a type to check

      [edit]Helper variable template

      template<class T>
      constexprbool is_final_v= is_final<T>::value;
      (since C++17)
      [edit]

      Inherited fromstd::integral_constant

      Member constants

      value
      [static]
      true ifT is a final class type,false otherwise
      (public static member constant)

      Member functions

      operator bool
      converts the object tobool, returnsvalue
      (public member function)
      operator()
      (C++14)
      returnsvalue
      (public member function)

      Member types

      Type Definition
      value_typebool
      typestd::integral_constant<bool, value>

      [edit]Notes

      std::is_final is introduced by the resolution ofLWG issue 2112.

      Aunion can be declaredfinal (andstd::is_final will detect that), even though unions cannot be used as bases in any case.

      Feature-test macroValueStdFeature
      __cpp_lib_is_final201402L(C++14)std::is_final

      [edit]Example

      Run this code
      #include <type_traits> class A{};static_assert(std::is_final_v<A>==false); class B final{};static_assert(std::is_final_v<B>==true); union U final{int x;double d;};static_assert(std::is_final_v<U>==true); int main(){}

      [edit]See also

      (C++11)
      checks if a type is a non-union class type
      (class template)[edit]
      checks if a type is a polymorphic class type
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/is_final&oldid=170051"

      [8]ページ先頭

      ©2009-2025 Movatter.jp