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

FreeBSD Manual Pages

  
 
  

home | help
std::filesy...ve_filename(3)  C++ Standard Libary std::filesy...ve_filename(3)

NAME
       std::filesystem::path::remove_filename	-   std::filesystem::path::re-
       move_filename

Synopsis
	  path&	remove_filename();  (since C++17)

	  Removes a single generic-format filename component (as  returned  by
       filename) from
	  the given generic-format path.

	  After	this function completes, has_filename returns false.

Parameters
	  (none)

Return value
	  *this

Exceptions
	  May throw implementation-defined exceptions.

Example
       // Run this code

	#include <filesystem>
	#include <iostream>
	namespace fs = std::filesystem;

	int main()
	{
	    fs::path p;
	    std::cout << std::boolalpha
		      <<   (p	=   "foo/bar").remove_filename()  <<  '\t'  <<
       p.has_filename()	<< '\n'
		      << (p = "foo/").remove_filename()	<< '\t'	<< p.has_file-
       name() << '\n'
		      << (p = "/foo").remove_filename()	<< '\t'	<< p.has_file-
       name() << '\n'
		      << (p = "/").remove_filename() <<	 '\t'  <<  p.has_file-
       name() << '\n'
		      <<  (p  =	 "").remove_filename()	<< '\t'	<< p.has_file-
       name() << '\n';
	}

Output:
	"foo/"	false
	"foo/"	false
	"/"	false
	"/"	false
	""	false

See also
	  filename	   returns the filename	path component
			   (public member function)
	  replace_filename replaces the	last path component with another path
			   (public member function)
	  has_filename	   checks if the corresponding	path  element  is  not
       empty
			   (public member function)

http://cppreference.com		  2024.06.10	  std::filesy...ve_filename(3)

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

home | help