std::filesystem::path:: begin, std::filesystem::path:: end
From cppreference.net
<
cpp
|
filesystem
|
path
C++
std::filesystem::path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
iterator begin
(
)
const
;
|
(1) | (C++17 이후) |
|
iterator end
(
)
const
;
|
(2) | (C++17 이후) |
1)
경로의 첫 번째 요소에 대한 반복자를 반환합니다. 경로가 비어 있는 경우, 반환된 반복자는
end()
와 같습니다.
2)
경로의 마지막 요소 바로 다음을 가리키는 반복자를 반환합니다. 이 반복자를 역참조하는 것은 정의되지 않은 동작입니다.
이 반복자 쌍으로 표시된 시퀀스는 다음으로 구성됩니다:
- root-name (있는 경우).
- root-directory (있는 경우).
- file-name 시퀀스(디렉토리 구분자는 생략).
- 경로의 마지막 file-name 뒤에 디렉토리 구분자가 있는 경우, end iterator 직전의 마지막 요소는 빈 요소입니다.
목차 |
매개변수
(없음)
반환값
1)
경로의 첫 번째 요소에 대한 반복자.
2)
경로의 끝을 지난 Iterator
예외
구현에서 정의된 예외를 던질 수 있습니다.
예제
이 코드 실행
#include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { const fs::path p = # ifdef _WIN32 "C:\\users\\abcdef\\AppData\\Local\\Temp\\"; # else "/home/user/.config/Cppcheck/Cppcheck-GUI.conf"; # endif std::cout << "Examining the path " << p << " through iterators gives\n"; for (auto it = p.begin(); it != p.end(); ++it) std::cout << *it << " │ "; std::cout << '\n'; }
가능한 출력:
--- Windows --- Examining the path "C:\users\abcdef\AppData\Local\Temp\" through iterators gives "C:" │ "/" │ "users" │ "abcdef" │ "AppData" │ "Local" │ "Temp" │ "" │ --- UNIX --- Examining the path "/home/user/.config/Cppcheck/Cppcheck-GUI.conf" through iterators gives "/" │ "home" │ "user" │ ".config" │ "Cppcheck" │ "Cppcheck-GUI.conf" │