Namespaces
Variants

std:: basic_format_arg

From cppreference.net
헤더에 정의됨 <format>
template < class Context >
class basic_format_arg ;
(C++20 이후)

서식 지정 인수에 대한 액세스를 제공합니다.

basic_format_arg 객체들은 일반적으로 std::make_format_args 에 의해 생성되며, std::visit_format_arg 또는 visit 멤버 함수들을 통해 접근됩니다 (C++26부터) .

A basic_format_arg 객체는 다음과 같은 타입들의 std::variant 를 포함하는 것처럼 동작합니다:

  • std:: monostate (객체가 기본 생성된 경우에만)
  • bool
  • Context :: char_type
  • int
  • unsigned int
  • long long int
  • unsigned long long int
  • float
  • double
  • long double
  • const Context :: char_type *
  • std:: basic_string_view < Context :: char_type >
  • const void *
  • basic_format_arg :: handle

목차

멤버 클래스

(C++20)
사용자 정의 타입의 객체 서식을 지정할 수 있는 타입 삭제 래퍼
(public member class)

멤버 함수

(생성자)
(C++20)
std::basic_format_arg 를 생성합니다
(public member function)
operator bool
(C++20)
현재 객체가 포맷팅 인자를 보유하고 있는지 확인합니다
(public member function)
visit
(C++26)
포함된 포맷팅 인자를 방문합니다
(public member function)

비멤버 함수

(C++20) (deprecated in C++26)
사용자 정의 포매터를 위한 인수 방문 인터페이스
(함수 템플릿)

std::basic_format_arg:: basic_format_arg

basic_format_arg ( ) noexcept ;
(C++20 이후)

기본 생성자. 포맷팅 인자를 보유하지 않는 basic_format_arg 를 생성합니다. 포함된 객체는 std::monostate 타입을 가집니다.

포맷팅 인자를 보유하는 basic_format_arg 를 생성하려면, std::make_format_args 를 사용해야 합니다.

std::basic_format_arg:: operator bool

explicit operator bool ( ) const noexcept ;
(C++20 이후)

* this 이 포맷팅 인자를 보유하고 있는지 확인합니다.

* this 이 포맷팅 인자를 보유하고 있는 경우(즉, 포함된 객체의 타입이 std::monostate 가 아닌 경우) true 를 반환하고, 그렇지 않으면 false 를 반환합니다.

std::basic_format_arg:: visit

template < class Visitor >
decltype ( auto ) visit ( this basic_format_arg arg, Visitor && vis ) ;
(1) (C++26부터)
template < class R, class Visitor >
R visit ( this basic_format_arg arg, Visitor && vis ) ;
(2) (C++26부터)

arg 에 포함된 객체에 방문자 vis 를 적용합니다.

visit 함수들은 vis 를 호출할 때 객체의 복사본이 사용되므로 호출된 basic_format_arg 객체를 수정하지 않습니다.

1) 다음 코드와 동등합니다: return std:: visit ( std:: forward < Visitor > ( vis ) , v ) ; , 여기서 v arg 에 포함된 std::variant 입니다.
2) 다음 코드와 동등합니다: return std:: visit < R > ( std:: forward < Visitor > ( vis ) , v ) ; , 여기서 v arg 에 포함된 std::variant 입니다.

참고 사항

기능 테스트 매크로 표준 기능
__cpp_lib_format 202306L (C++26) 멤버 visit

예제

참고 항목

모든 서식 지정 인수에 대한 접근을 제공하는 클래스
(클래스 템플릿)