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

FreeBSD Manual Pages

  
 
  

home | help
std::refere...m_temporary(3)  C++ Standard Libary std::refere...m_temporary(3)

NAME
       std::reference_converts_from_temporary	    -	   std::reference_con-
       verts_from_temporary

Synopsis
	  Defined in header <type_traits>
	  template< class T, class U >		     (since C++23)
	  struct reference_converts_from_temporary;

	  Let V	be std::remove_cv_t<U> if U is a scalar	type or	cv void, or  U
       otherwise. If T
	  is  a	 reference type, and given a hypothetic	expression e such that
       decltype(e) is V,
	  the variable definition T ref	= e; is	well-formed and	binds a	tempo-
       rary object to
	  ref, then provides the member	constant value equal to	 true.	Other-
       wise, value is
	  false.

	  If T is an lvalue reference type to a	const- but not volatile-quali-
       fied object type
	  or an	rvalue reference type, both std::remove_reference_t<T> and
	  std::remove_reference_t<U>  shall  be	complete types,	cv void, or an
       arrays of unknown
	  bound; otherwise the behavior	is undefined.

	  If an	instantiation of a template above depends, directly  or	 indi-
       rectly, on an
	  incomplete  type, and	that instantiation could yield a different re-
       sult if that type
	  were hypothetically completed, the behavior is undefined.

	  If  the  program  adds   specializations   for   std::reference_con-
       verts_from_temporary or
	  std::reference_converts_from_temporary_v, the	behavior is undefined.

Member constants
		   true	 if T is a reference type, a U value can be bound to T
       in
	  value	   copy-initialization,	and a temporary	object would be	 bound
       to the
	  [static] reference, 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
	  Type	     Definition
	  value_type bool
	  type	     std::integral_constant<bool, value>

Notes
	  std::reference_converts_from_temporary  can  be  used	 for rejecting
       some cases that
	  always produce dangling references.

Example
       // Run this code

	#include <type_traits>

	int main() {}

	static_assert(std::reference_converts_from_temporary_v<int&&, int>  ==
       true);
	static_assert(std::reference_converts_from_temporary_v<const	 int&,
       int> == true);
	static_assert(std::reference_converts_from_temporary_v<int&&,	int&&>
       == false);
	static_assert(std::reference_converts_from_temporary_v<const	 int&,
       int&&> == false);
	static_assert(std::reference_converts_from_temporary_v<int&&,  long&&>
       == true);
	static_assert(std::reference_converts_from_temporary_v<int&&, long> ==
       true);

See also
	  is_convertible
	  is_nothrow_convertible  checks  if  a	 type  can be converted	to the
       other type
	  (C++11)		 (class	template)
	  (C++20)
	  invoke		 invokes any Callable object with given	 argu-
       ments
	  invoke_r		 and possibility to specify return type
	  (C++17)		 (since	C++23)
	  (C++23)		 (function template)
	  bind			 binds one or more arguments to	a function ob-
       ject
	  (C++11)		 (function template)
	  visit			 calls the provided functor with the arguments
       held by one or
	  (C++17)		 more variants
				 (function template)
	  constructor		 constructs a new std::function	instance
				 (public   member   function   of   std::func-
       tion<R(Args...)>)
	  constructor		 constructs a new std::move_only_function  ob-
       ject
	  (C++23)		      (public	   member      function	    of
       std::move_only_function)
				 constructs the	task object
	  constructor		  (public  member   function   of   std::pack-
       aged_task<R(Args...)>)

http://cppreference.com		  2024.06.10	  std::refere...m_temporary(3)

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

home | help