std:: time_put_byname
|
헤더 파일에 정의됨
<locale>
|
||
|
template
<
class
CharT,
|
||
std::time_put_byname
는 생성 시 지정된 로캘의 시간 및 날짜 서식 규칙을 캡슐화하는
std::time_put
패싯입니다.
목차 |
특수화
표준 라이브러리는 다음 타입 요구사항을 만족하는 모든 특수화를 제공함을 보장합니다:
-
CharT는 char 와 wchar_t 중 하나이며, -
OutputIt는 LegacyOutputIterator 요구사항을 충족해야 합니다.
중첩 타입
| 유형 | 정의 |
char_type
|
CharT
|
iter_type
|
OutputIt
|
멤버 함수
|
(constructor)
|
새로운
time_put_byname
패싯을 생성합니다
(public member function) |
|
(destructor)
|
time_put_byname
패싯을 파괴합니다
(protected member function) |
std::time_put_byname:: time_put_byname
|
explicit
time_put_byname
(
const
char
*
name,
std::
size_t
refs
=
0
)
;
|
||
|
explicit
time_put_byname
(
const
std::
string
&
name,
std::
size_t
refs
=
0
)
;
|
(C++11 이후) | |
지정된 로캘 이름
name
에 대한 새로운
std::time_put_byname
패싯을 생성합니다.
refs 는 리소스 관리에 사용됩니다: refs == 0 인 경우, 구현은 이 패싯을 포함하는 마지막 std::locale 객체가 소멸될 때 패싯을 파괴합니다. 그렇지 않으면 객체는 파괴되지 않습니다.
매개변수
| name | - | 로캘의 이름 |
| refs | - | 패싯에 연결되는 참조 횟수 |
std::time_put_byname:: ~time_put_byname
|
protected
:
~time_put_byname ( ) ; |
||
파싯(facet)을 파괴합니다.
std:: time_put 에서 상속됨
데이터 멤버
| 멤버 | 설명 |
std::locale::id
id
[static]
|
패싯 의 식별자 |
멤버 함수
do_put
을 호출함
(
std::time_put<CharT,OutputIt>
의 public 멤버 함수)
|
보호된 멤버 함수
|
[virtual]
|
날짜/시간을 형식화하고 출력 스트림에 기록함
(
std::time_put<CharT,OutputIt>
의 virtual protected 멤버 함수)
|
예제
"C" 로케일을 사용하여 현재 시간을 출력하며,
time_put
패싯을 다양한
std::time_put_byname
패싯으로 대체합니다. 표시된 결과는 clang 컴파일러를 사용하여 얻은 것입니다.
#include <codecvt> #include <ctime> #include <iomanip> #include <iostream> int main() { std::time_t t = std::time(nullptr); std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv(std::cout.rdbuf()); std::wostream out(&conv); out.imbue(std::locale(out.getloc(), new std::time_put_byname<wchar_t>("ja_JP.utf8"))); out << std::put_time(std::localtime(&t), L"%A %c") << '\n'; out.imbue(std::locale(out.getloc(), new std::time_put_byname<wchar_t>("ru_RU.utf8"))); out << std::put_time(std::localtime(&t), L"%A %c") << '\n'; out.imbue(std::locale(out.getloc(), new std::time_put_byname<wchar_t>("sv_SE.utf8"))); out << std::put_time(std::localtime(&t), L"%A %c") << '\n'; }
가능한 출력:
木曜日 2023年10月05日 19時44分51秒 Четверг Чт 05 окт 2023 19:44:51 torsdag tor 5 okt 2023 19:44:51
참고 항목
|
std::tm
내용을 문자 시퀀스로 출력하기 위해 형식화
(클래스 템플릿) |