format_basic_format_args
format_basic_format_args (서식 인자 접근)
이 페이지는 C++20에서 도입된 std::basic_format_args 클래스 템플릿에 대해 설명해요. 이 타입은 std::format 함수군에 전달할 서식 인자들에 대한 접근을 제공해요. std::make_format_args나 std::make_wformat_args로 생성된 인자 저장소를 참조해요.
출처: cppreference
본문
<format> 헤더에 정의돼 있어요.
| 정의 | ||
|---|---|---|
template < class Context > class basic_format_args ; |
(1) | (since C++20) |
using format_args = basic_format_args < std :: format_context > ; |
(2) | (since C++20) |
using wformat_args = basic_format_args < std :: wformat_context > ; |
(3) | (since C++20) |
서식 인자에 대한 접근을 제공해요.
멤버 함수
| 이름 | 설명 |
|---|---|
| (constructor) | basic_format_args 객체를 생성해요 (공개 멤버 함수) |
| get | 주어진 인덱스의 서식 인자를 반환해요 (공개 멤버 함수) |
std::basic_format_args::basic_format_args
template < class ... Args > basic_format_args ( const /*format-arg-store*/ < Context , Args ... >& store ) noexcept ;
std::make_format_args 또는 std::make_wformat_args 호출 결과로부터 basic_format_args 객체를 생성해요.
std::basic_format_args::get
std :: basic_format_arg < Context > get ( std :: size_t i ) const noexcept ;
args에서 i번째 인자를 담은 std::basic_format_arg를 반환해요. 여기서 args는 std::make_format_args 또는 std::make_wformat_args에 전달된 매개변수 팩이에요.
해당 서식 인자가 없다면 (즉, *this가 기본 생성되었거나 i가 서식 인자 개수보다 작지 않다면) 기본 생성된 std::basic_format_arg (std::monostate 객체를 담은)를 반환해요.
추론 가이드 (Deduction guides)
template < class Context , class ... Args > basic_format_args ( /*format-arg-store*/ < Context , Args ... > ) -> basic_format_args < Context > ;
(since C++20)
참고 사항 (Notes)
std::basic_format_args는 참조 의미론을 가져요. *this가 store보다 오래 살아남지 않도록 해야 하며, store 역시 std::make_format_args 또는 std::make_wformat_args에 전달된 인자들보다 오래 살아남지 않아야 해요. 이는 프로그래머의 책임이에요.
예제 (Example)
| 이 섹션은 불완전해요. 이유: 예제 없음 |
|---|
결함 보고서 (Defect reports)
다음 동작 변경 결함 보고서는 이전에 발표된 C++ 표준에 소급 적용됐어요.
| DR | 적용 대상 | 발표된 동작 | 올바른 동작 |
|---|---|---|---|
| P2216R3 | C++20 | format_args_t는 vformat_to의 과매개변수화로 제공됨 |
제거됨 |
| LWG 3810 | C++20 | basic_format_args에 추론 가이드 없음 |
추가됨 |
| LWG 4106 | C++20 | basic_format_args는 기본 생성 가능했음 |
기본 생성자 제거됨 |
같이 보기 (See also)
basic_format_arg (C++20) |
사용자 정의 포맷터를 위한 서식 인자 접근을 제공하는 클래스 템플릿 (클래스 템플릿) [edit] |
|---|