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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::map::at - std::map::at

Synopsis
	  T& at( const Key& key	);	       (1)
	  const	T& at( const Key& key )	const; (2)
	  template< class K >		       (3) (since C++26)
	  T& at( const K& x );
	  template< class K >		       (4) (since C++26)
	  const	T& at( const K&	x ) const;

	  Returns  a  reference	to the mapped value of the element with	speci-
       fied key. If no
	  such element exists,	an  exception  of  type	 std::out_of_range  is
       thrown.

	  1,2) The key is equivalent to	key.
	  3,4)	The  key  compares equivalent to the value x. The reference to
       the mapped value
	  is obtained as if by expression this->find(x)->second.
	  The expression this->find(x) must be well-formed and	have  well-de-
       fined behavior,
	  otherwise the	behavior is undefined.
	  These	overloads participate in overload resolution only if the qual-
       ified-id
	  Compare::is_transparent is valid and denotes a type. It allows call-
       ing this	function
	  without constructing an instance of Key.

Parameters
	  key -	the key	of the element to find
	  x    - a value of any	type that can be transparently compared	with a
       key

Return value
	  A reference to the mapped value of the requested element.

Exceptions
	  1,2) std::out_of_range if the	container does	not  have  an  element
       with the	specified
	  key.
	  3,4)	std::out_of_range if the container does	not have the specified
       element,	that
	  is, if find(x) == end() is true.

Complexity
	  Logarithmic in the size of the container.

Notes
		       Feature-test    macro		       Value	   Std
       Feature
									Het-
       erogeneous
									over-
       loads for the
									re-
       maining member
	  __cpp_lib_associative_heterogeneous_insertion	 202311L (C++26) func-
       tions in	ordered
									and
       unordered
									asso-
       ciative
									con-
       tainers.	(3,4)

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	464    C++98	   map	did  not  have	this  member  function
       added
	  LWG  703   C++98	 the  complexity   requirement	 was   missing
       added
	  LWG  2007  C++98	 the  return  value  referred to the requested
       refers to its mapped
			      element
       value

See also
	  operator[] access or insert specified	element
		     (public member function)

Category:
	    * Todo no example

http://cppreference.com		  2024.06.10		       std::map::at(3)

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

home | help