Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::filesystem::path::append,std::experimental::filesystem::path::operator/=

      From cppreference.com
      <cpp‎ |experimental‎ |fs‎ |path
       
       
       
      Filesystem library
      Classes
      Functions
      File types
       
      path
      Member functions
      Path decomposition
      Non-member functions
       
      path& operator/=(const path& p);
      (1)(filesystem TS)
      template<class Source>
      path& operator/=(const Source& source);
      (2)(filesystem TS)
      template<class Source>
      path& append(const Source& source);
      (3)(filesystem TS)
      template<class InputIt>
      path& append( InputIt first, InputIt last);
      (4)(filesystem TS)
      1) First, appends the preferred directory separator tothis, except if any of the following conditions is true:
      * the separator would be redundant (*this already ends with a separator).
      **this is empty, or adding it would turn a relative path to an absolute path in some other way.
      *p is an empty path.
      *p.native() begins with a directory separator.
      Then, appendsp.native() to the pathname maintained by*this.
      2,3) Same as(1), but accepts anystd::basic_string, null-terminated multicharacter string, or an input iterator pointing to a null-terminated multicharacter sequence.
      4) Same as(1), but accepts any iterator pair that designates a multicharacter string.

      Contents

      [edit]Parameters

      p - pathname to append
      source -std::basic_string, null-terminated multicharacter string, or an input iterator pointing to a null-terminated multicharacter sequence, which represents a path name (either in portable or in native format)
      first, last - pair ofLegacyInputIterators that specify a multicharacter sequence that represents a path name
      Type requirements
      -
      InputIt must meet the requirements ofLegacyInputIterator.
      -
      The value type ofInputIt must be one of the encoded character types (char,wchar_t,char16_t andchar32_t).

      [edit]Return value

      *this

      [edit]Exceptions

      May throwfilesystem_error on underlying OS API errors orstd::bad_alloc if memory allocation fails.

      [edit]Example

      Run this code
      #include <experimental/filesystem>#include <iostream>namespace fs= std::experimental::filesystem; int main(){    fs::path p1="C:";    p1/="Users";// does not insert a separator// "C:Users" is a relative path in Windows// adding directory separator would turn it to an absolute pathstd::cout<<"\"C:\" /\"Users\" == "<< p1<<'\n';    p1/="batman";// inserts fs::path::preferred_separator, '\' on Windowsstd::cout<<"\"C:\" /\"Users\" /\"batman\" == "<< p1<<'\n';}

      Possible output:

      "C:" / "Users" == "C:Users""C:" / "Users" / "batman" == "C:Users\batman"

      [edit]See also

      concatenates two paths without introducing a directory separator
      (public member function)[edit]
      concatenates two paths with a directory separator
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/fs/path/append&oldid=154861"

      [8]ページ先頭

      ©2009-2026 Movatter.jp