[βNote: The format conversions described in this section are not applied on POSIX-based operating systems because on these systems:
The generic format is acceptable as a native path.
There is no need to distinguish between native format and generic format in function arguments.
Paths for regular files and paths for directories share the same syntax.
βββend noteβ]
Several functions are defined to accept detected-format arguments, which are character sequences. A detected-format argument represents a path using either a pathname in the generic format or a pathname in the native format. Such an argument is taken to be in the generic format if and only if it matches the generic format and is not acceptable to the operating system as a native path.
[βNote: Some operating systems may have no unambiguous way to distinguish between native format and generic format arguments. This is by design as it simplifies use for operating systems that do not require disambiguation. An implementation for an operating system where disambiguation is required is permitted to distinguish between the formats. βββend noteβ]
Pathnames are converted as needed between the generic and native formats in an operating-system-dependent manner. Let G(n) and N(g) in a mathematical sense be the implementation's functions that convert native-to-generic and generic-to-native formats respectively. If g=G(n) for some n, then G(N(g))=g; if n=N(g) for some g, then N(G(n))=n. [βNote: Neither G nor N need be invertible. βββend noteβ]
If the native format requires paths for regular files to be formatted differently from paths for directories, the path shall be treated as a directory path if its last element is a directory-separator, otherwise it shall be treated as a path to a regular file.
[βNote: A path stores a native format pathname ([fs.path.native.obs]) and acts as if it also stores a generic format pathname, related as given below. The implementation may generate the generic format pathname based on the native format pathname (and possibly other information) when requested. βββend noteβ]
When a path is constructed from or is assigned a single representation separate from any path, the other representation is selected by the appropriate conversion function (G or N).
When the (new) value p of one representation of a path is derived from the representation of that or another path, a value q is chosen for the other representation. The value q converts to p (by G or N as appropriate) if any such value does so; q is otherwise unspecified. [βNote: If q is the result of converting any path at all, it is the result of converting p. βββend noteβ]
For member function arguments that take character sequences representing paths and for member functions returning strings, value type and encoding conversion is performed if the value type of the argument or return value differs from pathβ::βvalue_Βtype. For the argument or return value, the method of conversion and the encoding to be converted to is determined by its value type:
char: The encoding is the native narrow encoding ([fs.def.native.encode]). The method of conversion, if any, is operating system dependent. [βNote: For POSIX-based operating systems pathβ::βvalue_Βtype is char so no conversion from char value type arguments or to char value type return values is performed. For Windows-based operating systems, the native narrow encoding is determined by calling a Windows API function. βββend noteβ] [βNote: This results in behavior identical to other C and C++ standard library functions that perform file operations using narrow character strings to identify paths. Changing this behavior would be surprising and error prone. βββend noteβ]
wchar_Βt: The encoding is the native wide encoding. The method of conversion is unspecified. [βNote: For Windows-based operating systems pathβ::βvalue_Βtype is wchar_Βt so no conversion from wchar_Βt value type arguments or to wchar_Βt value type return values is performed. βββend noteβ]
char16_Βt: The encoding is UTF-16. The method of conversion is unspecified.
char32_Βt: The encoding is UTF-32. The method of conversion is unspecified.