2798. Definition of path in terms of a string

Section: 30.11.7 [fs.class.path] Status: Resolved Submitter: Billy O'Neal III Opened: 2016-11-10 Last modified: 2017-07-18

Priority: 2

View all other issues in [fs.class.path].

View all issues with Resolved status.

Discussion:

Addresses US 44, LWG 2734

The explicit definition of path in terms of a string requires that the abstraction be leaky. Consider that the meaning of the expression p += '/' has very different behavior in the case that p is empty; that a path can uselessly contain null characters; and that iterators must be constant to avoid having to reshuffle the packed string.

Suggested resolution:

Define member functions to express a path as a string, but define its state in terms of the abstract sequence of components (including the leading special components) already described by the iterator interface. Remove members that rely on arbitrary manipulation of a string value.

[2016-11-12, Issaquah]

Sat PM: "Looks good"

[Issues Telecon 16-Dec-2016]

Priority 2; should be addressed by omnibus Filesystem paper.

[Kona, 2017-03]

This is resolved by p0492r2.

Proposed resolution:

This wording is relative to N4606.

  1. Edit [fs.path.concat] as follows:

    path& operator+=(const path& x);
    path& operator+=(const string_type& x);
    path& operator+=(basic_string_view<value_type> x);
    path& operator+=(const value_type * x);
    path& operator+=(value_type x);
    template <class Source>
        path& operator+=(const Source& x);
    template <class EcharT>
        path& operator+=(EcharT x);
    template <class Source>
        path& concat(const Source& x);
    template <class InputIterator>
        path& concat(InputIterator first, InputIterator last);
    

    -1- Postcondition: native() == prior_native + effective-argument, where prior_native is native() prior to the call to operator+=, and effective-argument is:

    • if x is present and is const path&, x.native(); otherwise,
    • if source is present, the effective range of source [ath.re]; otherwise,
    • >if first and last are present, the range [first, last); otherwise,
    • x.

    If the value type of effective-argument would not be path::value_type, the acctual argument or argument range is first converted [ath.type.cv] so that effective-argument has value type path::value_type. Effects: Equivalent to pathname.append(path(x).native()) [Note: This directly manipulates the value of native() and may not be portable between operating systems. — end note]

    -2- Returns: *this.

    template <class InputIterator>
        path& concat(InputIterator first, InputIterator last);
    

    -?- Effects: Equivalent to pathname.append(path(first, last).native()) [Note: This directly manipulates the value of native() and may not be portable between operating systems. — end note]

    -?- Returns: *this.