Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::filesystem::path::operator=

      From cppreference.com
      <cpp‎ |filesystem‎ |path
       
       
      Filesystem library
      Classes
      Functions
      File types
       
      std::filesystem::path
      Member types
      Member constants
      Member functions
      Path decomposition
      Non-member functions
      (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
      Helper classes
       
      path& operator=(const path& p);
      (1)(since C++17)
      path& operator=( path&& p)noexcept;
      (2)(since C++17)
      path& operator=( string_type&& source);
      (3)(since C++17)
      template<class Source>
      path& operator=(const Source& source);
      (4)(since C++17)
      1) Replaces the contents of*this with a pathname whose both native and generic format representations equal those ofp.
      2) Replaces the contents of*this with a pathname whose both native and generic format representations equal those ofp, possibly using move semantics:p is left in a valid, but unspecified state.
      3) Replaces the contents of*this with a new path value constructed from detected-formatsource, which is left in valid, but unspecified state. Equivalent toassign(std::move(source)).
      4) Replaces the contents of*this with a new path value constructed from detected-formatsource as if by overload(4) of thepath constructor. Equivalent toassign(source).

      (4) participates in overload resolution only ifSource andpath are not the same type, and either:

      Contents

      [edit]Parameters

      p - a path to assign
      source - astd::basic_string,std::basic_string_view, pointer to a null-terminated character/wide character string, or an input iterator that points to a null-terminated character/wide character sequence. The character type must be one ofchar,char8_t,(since C++20)char16_t,char32_t,wchar_t

      [edit]Return value

      *this

      [edit]Example

      Run this code
      #include <filesystem>namespace fs= std::filesystem; int main(){    fs::path p="C:/users/abcdef/AppData/Local";    p= p/"Temp";// move assignmentconstwchar_t* wstr= L"D:/猫.txt";    p= wstr;// assignment from a source}

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3244C++17constraint thatSource cannot bepath was missingadded

      [edit]See also

      assigns contents
      (public member function)[edit]
      constructs apath
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/path/operator%3D&oldid=158063"

      [8]ページ先頭

      ©2009-2025 Movatter.jp