[fs.path.append] # 31 Input/output library [[input.output]](./#input.output) ## 31.12 File systems [[filesystems]](filesystems#fs.path.append) ### 31.12.6 Class path [[fs.class.path]](fs.class.path#fs.path.append) #### 31.12.6.5 Members [[fs.path.member]](fs.path.member#fs.path.append) #### 31.12.6.5.3 Appends [fs.path.append] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14340) The append operations use operator/= to denote their semantic effect of appending[*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]") when needed[.](#1.sentence-1) [🔗](#lib:operator/=,path) `path& operator/=(const path& p); ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14350) *Effects*: If p.is_absolute() || (p.has_root_name() && p.root_name() != root_name()), then operator=(p)[.](#2.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14355) Otherwise, modifies *this as if by these steps: - [(3.1)](#3.1) If p.has_root_directory(), then removes any root directory and relative path from the generic format pathname[.](#3.1.sentence-1) Otherwise, if !has_root_directory() && is_absolute() is true or if has_filename() is true, then appends path​::​preferred_separator to the generic format pathname[.](#3.1.sentence-2) - [(3.2)](#3.2) Then appends the native format pathname of p, omitting any [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]") from its generic format pathname, to the native format pathname[.](#3.2.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14370) [*Example [1](#example-1)*: Even if //host is interpreted as a [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]"), both of the paths path("//host")/"foo" and path("//host/")/"foo" equal "//host/foo" (although the former might use backslash as the preferred separator)[.](#4.sentence-1) Expression examples:// On POSIX, path("foo") /= path(""); // yields path("foo/") path("foo") /= path("/bar"); // yields path("/bar")// On Windows, path("foo") /= path(""); // yields path("foo\\") path("foo") /= path("/bar"); // yields path("/bar") path("foo") /= path("c:/bar"); // yields path("c:/bar") path("foo") /= path("c:"); // yields path("c:") path("c:") /= path(""); // yields path("c:") path("c:foo") /= path("/bar"); // yields path("c:/bar") path("c:foo") /= path("c:bar"); // yields path("c:foo\\bar") — *end example*] [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14394) *Returns*: *this[.](#5.sentence-1) [🔗](#lib:operator/=,path_) `template path& operator/=(const Source& source); template path& append(const Source& source); ` [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14409) *Effects*: Equivalent to: return operator/=(path(source)); [🔗](#lib:operator/=,path__) `template path& append(InputIterator first, InputIterator last); ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14422) *Effects*: Equivalent to: return operator/=(path(first, last));