std::experimental::filesystem::temp_directory_path

From cppreference.com
< cpp‎ | experimental‎ | fs
Defined in header <experimental/filesystem>
path temp_directory_path();
(1) (filesystem TS)
path temp_directory_path( error_code& ec );
(2) (filesystem TS)

Returns an unspecified directory suitable for temporary files.

An error is reported if the path to be returned does not exist or is not directory.

The second version returns path() and sets ec to an appropriate error code if error occurs. Otherwise, ec is cleared via ec.clear().

Contents

[edit] Parameters

(none)

[edit] Return value

A directory suitable for temporary files.

[edit] Exceptions

1) filesystem_error if an error occurs.
2)
noexcept specification:  
noexcept
  

[edit] Example

#include <filesystem>
#include <iostream>
 
int main()
{
    namespace fs = std::experimental::filesystem;
    std::cout << fs::temp_directory_path() << '\n';
}

Output:

/tmp

[edit] See also

Template:cpp/experimental/fs/dsc unique path