< cpp‎ | experimental‎ | fs‎ | path
Technical specifications
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
path stem() const;
(filesystem TS)

Returns the filename identified by the path stripped of its extension.

Returns the substring from the beginning of filename() up to and not including the last period (.) character.

If the filename is one of the special filesystem components dot or dot-dot, or if it has no periods, the function returns the entire filename().


[edit] Parameters


[edit] Return value

The stem of the filename identified by the path.

[edit] Exceptions

May throw implementation-defined exceptions.

[edit] Example

#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
    std::cout << fs::path("/foo/bar.txt").stem() << '\n'
              << fs::path("/foo/.bar").stem() << '\n';
    for (fs::path p = ""; !p.extension().empty(); p = p.stem())
        std::cout << p.extension() << '\n';



[edit] See also

returns the filename path component
(public member function) [edit]
returns the file extension path component
(public member function) [edit]