[fs.op.weakly.canonical]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.op.weakly.canonical)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.weakly.canonical)

#### 31.12.13.40 Weakly canonical [fs.op.weakly.canonical]

[ð](#lib:weakly_canonical)

`path filesystem::weakly_canonical(const path& p);
path filesystem::weakly_canonical(const path& p, error_code& ec);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18811)

*Effects*: Using status(p) or status(p, ec), respectively,
 to determine existence,
 return a path composed by operator/= from the result of calling canonical with a path argument composed of
 the leading elements of p that exist, if any, followed by
 the elements of p that do not exist, if any[.](#1.sentence-1)

For the first form, canonical is called without an error_code argument[.](#1.sentence-2)

For the second form, canonical is called
 with ec as an error_code argument, and path() is returned at the first error occurrence, if any[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18827)

*Postconditions*: The returned path is in normal form ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format"))[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18831)

*Returns*: p with symlinks resolved and
 the result normalized ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format"))[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18836)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#4.sentence-1)
