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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::iostream_category -	std::iostream_category

Synopsis
	  Defined in header <ios>
	  const	 std::error_category&  iostream_category()  noexcept;	(since
       C++11)

	  Obtains a reference to the static error category object for iostream
       errors. The
	  object is required to	 override  the	virtual	 function  error_cate-
       gory::name() to return
	  a  pointer  to  the  string "iostream". It is	used to	identify error
       codes provided in
	  the exceptions of type std::ios_base::failure.

Parameters
	  (none)

Return value
	  A reference to the static object of unspecified  runtime  type,  de-
       rived from
	  std::error_category.

Example
       // Run this code

	#include <fstream>
	#include <iostream>

	int main()
	{
	    std::ifstream f("doesn't exist");
	    try
	    {
		f.exceptions(f.failbit);
	    }
	    catch (const std::ios_base::failure& e)
	    {
		std::cout << "Caught an	ios_base::failure.\n"
			  << "Error code: " << e.code().value()
			  << " (" << e.code().message()	<< ")\n"
			  <<  "Error category: " << e.code().category().name()
       << '\n';

	    }
	}

Possible output:
	Caught an ios_base::failure.
	Error code: 1 (unspecified iostream_category error)
	Error category:	iostream

	  Defect reports

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

	     DR	   Applied to		 Behavior as published		  Cor-
       rect behavior
	  LWG 2087 C++11      iostream_category	was not	declared noexcept  de-
       clared noexcept

See also
	  failure stream exception
		  (public member class of std::ios_base)
	  io_errc the IO stream	error codes
	  (C++11) (enum)

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

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

home | help