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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::copyable_function -	std::copyable_function

Synopsis
	  Defined in header <functional>
	  template<  class...  >				    (1)	(since
       C++26)
	  class	copyable_function; // not defined
	  template< class R, class... Args >

	  class	copyable_function<R(Args...)>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) noexcept>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) &>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) & noexcept>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) &&>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) &&	 noexcept>;	   (2)	(since
       C++26)
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) const>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) const noexcept>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) const &>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) const & noexcept>;
	  template< class R, class... Args >
	  class	copyable_function<R(Args...) const &&>;
	  template< class R, class... Args >

	  class	copyable_function<R(Args...) const && noexcept>;

	  Class	 template std::copyable_function is a general-purpose polymor-
       phic function
	  wrapper. std::copyable_function objects can  store  and  invoke  any
       CopyConstructible
	  Callable target  functions, lambda expressions, bind expressions, or
       other function
	  objects,  as	well  as  pointers to member functions and pointers to
       member objects.

	  The stored callable  object  is  called  the	target	of  std::copy-
       able_function. If a
	  std::copyable_function  contains  no target, it is called empty. Un-
       like std::function,
	  invoking an empty std::copyable_function results in undefined	behav-
       ior.

	  std::copyable_functions supports every possible combination  of  cv-
       qualifiers,
	  ref-qualifiers,  and noexcept-specifiers not including volatile pro-
       vided in	its
	  template parameter. These qualifiers	and  specifier	(if  any)  are
       added to	its
	  operator().

	  std::copyable_function   satisfies   the  requirements  of  CopyCon-
       structible and
	  CopyAssignable.

Member types
	  Type	      Definition
	  result_type R

Member functions
	  constructor	constructs a new std::copyable_function	object
	  (C++26)	(public	member function)
	  destructor	destroys a std::copyable_function object
	  (C++26)	(public	member function)
	  operator=	replaces or destroys the target
	  (C++26)	(public	member function)
	  swap		swaps the targets of  two  std::copyable_function  ob-
       jects
	  (C++26)	(public	member function)
	  operator bool	checks if the std::copyable_function has a target
	  (C++26)	(public	member function)
	  operator()	invokes	the target
	  (C++26)	(public	member function)

Non-member functions
	  swap(std::copyable_function) overloads the std::swap algorithm
	  (C++26)		       (function)
	  operator==			compares a std::copyable_function with
       nullptr
	  (C++26)		       (function)

Notes
	  Implementations may store a callable object of small size within the
	  std::copyable_function object. Such small object optimization	is ef-
       fectively
	  required for function	pointers and  std::reference_wrapper  special-
       izations, and can
	  only	be  applied  to	 types	T  for which std::is_nothrow_move_con-
       structible_v<T> is
	  true.

	      Feature-test macro       Value	Std	     Feature
	  __cpp_lib_copyable_function 202306L (C++26) std::copyable_function

Example
	   This	section	is incomplete
	   Reason: example

See also
	  function	     wraps callable object of any  copy	 constructible
       type with
	  (C++11)	     specified function	call signature
			     (class template)
	  move_only_function  wraps callable object of any type	with specified
       function	call
	  (C++23)	     signature
			     (class template)

Category:
	    * Todo with	reason

http://cppreference.com		  2024.06.10	     std::copyable_function(3)

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

home | help