Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::is_abstract(3)	      C++ Standard Libary	   std::is_abstract(3)

NAME
       std::is_abstract	- std::is_abstract

Synopsis
	  Defined in header <type_traits>
	  template< class T >		   (since C++11)
	  struct is_abstract;

	  If  T	is an abstract class (that is, a non-union class that declares
       or inherits at
	  least	one pure virtual function), provides the member	constant value
       equal to	true.
	  For any other	type, value is false.

	  If T is a non-union class type, T shall be a complete	 type;	other-
       wise, the behavior
	  is undefined.

	  The behavior of a program that adds specializations for is_abstract
	  or is_abstract_v
	  (since C++17)	is undefined.

Template parameters
	  T - a	type to	check

	 Helper	variable template

	  template< class T >						(since
       C++17)
	  inline constexpr bool	is_abstract_v =	is_abstract<T>::value;

       Inherited from std::integral_constant

Member constants
	  value	   true	if T is	an abstract class type , false otherwise
	  [static] (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
	  Type	     Definition
	  value_type bool
	  type	     std::integral_constant<bool, value>

Example
       // Run this code

	#include <iostream>
	#include <type_traits>

	struct A {
	    int	m;
	};

	struct B {
	    virtual void foo();
	};

	struct C {
	    virtual void foo() = 0;
	};

	struct D : C {};

	int main()
	{
	    std::cout << std::boolalpha;
	    std::cout << std::is_abstract<A>::value << '\n';
	    std::cout << std::is_abstract<B>::value << '\n';
	    std::cout << std::is_abstract<C>::value << '\n';
	    std::cout << std::is_abstract<D>::value << '\n';
	}

Output:
	false
	false
	true
	true

See also
	  is_class	 checks	if a type is a non-union class type
	  (C++11)	 (class	template)
	  is_polymorphic checks	if a type is a polymorphic class type
	  (C++11)	 (class	template)

http://cppreference.com		  2022.07.31		   std::is_abstract(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::is_abstract&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help