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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::expected::value - std::expected::value

Synopsis
	  T is not (possibly cv-qualified) void
	  constexpr T& value() &;		(1) (since C++23)
	  constexpr const T& value() const&;	(2) (since C++23)
	  constexpr T&&	value()	&&;		(3) (since C++23)
	  constexpr const T&& value() const&&;	(4) (since C++23)
	  T is (possibly cv-qualified) void
	  constexpr void value() const&;	(5) (since C++23)
	  constexpr void value() &&;		(6) (since C++23)

	  If *this contains an expected	value, returns a reference to the con-
       tained value.
	  Returns nothing if T is (possibly cv-qualified) void.

	  Otherwise,   throws	an  exception  of  type	 std::bad_expected_ac-
       cess<std::decay_t<E>>
	  that contains	a copy of error().

	  1,2) If std::is_copy_constructible_v<E> is  false,  the  program  is
       ill-formed.
	  3,4)	   If	 std::is_copy_constructible_v<E>    or	  std::is_con-
       structible_v<E,
	  decltype(std::move(error()))>	is false, the program is ill-formed.
	  5) If	std::is_copy_constructible_v<E>	is false, the program is  ill-
       formed.
	  6)  If std::is_move_constructible_v<E> is false, the program is ill-
       formed.

Parameters
	  (none)

Return value
	  1-4) The expected value contained in *this.
	  5,6) (none)

Exceptions
	  1,2,5)  Throws  std::bad_expected_access(std::as_const(error()))  if
       *this contains an
	  unexpected value.
	  3,4,6)  Throws std::bad_expected_access(std::move(error())) if *this
       contains	an
	  unexpected value.

Example
	   This	section	is incomplete
	   Reason: no example

	  Defect reports

	  The following	behavior-changing defect reports were applied retroac-
       tively to
	  previously published C++ standards.

	     DR	     Applied	to		   Behavior    as    published
       Correct behavior
	  LWG	 3940	 C++23	       E    was	   not	  required    to    be
       required
			      copy/move-constructible for overloads (5,6)

See also
	  value_or	      returns the expected value if  present,  another
       value otherwise
			      (public member function)
	  operator->	      accesses the expected value
	  operator*	      (public member function)
	  error		      returns the unexpected value
			      (public member function)
	  bad_expected_access  exception  indicating  checked access to	an ex-
       pected that contains
	  (C++23)	      an unexpected value
			      (class template)

Category:
	    * Todo no example

http://cppreference.com		  2024.06.10	       std::expected::value(3)

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

home | help