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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::basic_filebuf::close - std::basic_filebuf::close

Synopsis
	  std::basic_filebuf<CharT, Traits>* close();

	  If a put area	exist (e.g. file was opened for	writing), first	calls
	  overflow(Traits::eof()) to write all pending output to the file, in-
       cluding any
	  unshift sequences.

	  If  the  most	 recently  called  function, out of underflow(), over-
       flow(), seekpos(), and
	  seekoff(), was overflow(), then calls	std::codecvt::unshift(),  per-
       haps multiple
	  times, to determine the unshift sequence according to	the imbued lo-
       cale, and writes
	  that sequence	to file	with overflow(Traits::eof()).

	  Then,	 closes	the file as if by calling std::fclose(), regardless of
       whether any of
	  the preceding	calls succeeded	or failed.

	  If  any  of  the  function  calls  made,  including  the   call   to
       std::fclose(), fails,
	  returns  a null pointer. If any of the function calls	made throws an
       exception, the
	  exception is caught and rethrown after closing the file. If the file
       is already
	  closed, returns a null pointer right away.

	  In any case, updates the private member variable that	is accessed by
       is_open().

Parameters
	  (none)

Return value
	  this on success, a null pointer on failure.

Notes
	  close() is typically	called	through	 the  destructor  of  std::ba-
       sic_filebuf (which, in
	  turn,	is typically called by the destructor of std::basic_fstream.

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 443 C++98	     the file was written using	    changed  to	 over-
       flow(Traits::eof())
			     overflow(EOF)
			     it	was unclear how	to handle
	  LWG  622 C++98      the			    it is rethrown af-
       ter closing the
			     exception thrown during	   file
			     closing

See also
	  is_open      checks if the associated	file is	open
		       (public member function)
	  destructor   destructs a basic_filebuf object	and closes the file if
       it is open
	  [virtual]    (virtual	public member function)

Category:
	    * Todo no example

http://cppreference.com		  2024.06.10	  std::basic_filebuf::close(3)

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

home | help