名前空間
変種
操作

std::chrono::ambiguous_local_time

From cppreference.com
< cpp‎ | chrono
 
 
 
ヘッダー <chrono> で定義
class ambiguous_local_time;
(C++20以降)

曖昧なstd::chrono::local_timeを、std::chrono::choosechoose::earliestchoose::latestなど)を指定せずにstd::chrono::sys_timeに変換しようとしたことを報告するためにスローされるオブジェクトの型を定義します。

この例外は、std::chrono::time_zone::to_sysおよびそれを呼び出す関数(std::chrono::local_timeを引数に取るstd::chrono::zoned_timeのコンストラクタなど)によってスローされます。

cpp/error/exceptioncpp/error/runtime errorstd-chrono-ambiguous local time-inheritance.svg

継承図

目次

[編集] メンバ関数

(コンストラクタ)
例外オブジェクトを構築する
(public member function)
operator=
例外オブジェクトを置き換えます
(public member function)
what
説明文字列を返す
(public member function)

std::chrono::ambiguous_local_time::ambiguous_local_time

template< class Duration >

ambiguous_local_time( const std::chrono::local_time<Duration>& tp,

                      const std::chrono::local_info& i );
(1) (C++20以降)
ambiguous_local_time( const ambiguous_local_time& other ) noexcept;
(2) (C++20以降)

例外オブジェクトを構築します。

1) what()が返す説明文字列は、次のコードの後のos.str()によって生成されるものと同等です。
std::ostringstream os;
os << tp << " is ambiguous.  It could be\n"
   << tp << ' ' << i.first.abbrev << " == "
   << tp - i.first.offset << " UTC or\n"
   << tp << ' ' << i.second.abbrev  << " == "
   << tp - i.second.offset  << " UTC";
i.result != std::chrono::local_info::ambiguousの場合、動作は未定義です。
2) コピーコンストラクタ。 *thisotherが両方とも動的型std::chrono::ambiguous_local_timeを持つ場合、std::strcmp(what(), other.what()) == 0となります。

パラメータ

tp - 変換が試みられた時刻
i - 変換試行の結果を説明するstd::chrono::local_info
その他 - コピーする別のambiguous_local_time

例外

std::bad_allocをスローする可能性があります。

注釈

std::exceptionから派生した標準ライブラリクラスのコピーは例外をスローすることが許可されていないため、このメッセージは通常、内部的に個別に割り当てられた参照カウント文字列として格納されます。

std::chrono::ambiguous_locale_time::operator=

ambiguous_locale_time& operator=( const ambiguous_locale_time& other ) noexcept;
(C++20以降)

otherの内容を代入します。*thisotherが両方とも動的型std::chrono::ambiguous_locale_timeを持つ場合、代入後、std::strcmp(what(), other.what()) == 0となります。

パラメータ

その他 - 割り当てる別の例外オブジェクト

戻り値

*this

std::chrono::ambiguous_locale_time::what

virtual const char* what() const noexcept;
(C++20以降)

説明文字列を返します。

戻り値

説明情報を含む、実装定義のヌル終端文字列へのポインタ。この文字列は std::wstring として変換および表示するのに適しています。このポインタは、それが取得された例外オブジェクトが破棄されるか、例外オブジェクトの非 const メンバー関数(例:コピー代入演算子)が呼び出されるまで、少なくとも有効であることが保証されます。

返された文字列は、定数評価中に通常のリテラルエンコーディングでエンコードされます。

(C++26以降)

注釈

実装は what() をオーバーライドすることが許可されていますが、必須ではありません。

std::runtime_error から継承


std::exception から継承

メンバ関数

例外オブジェクトを破棄する
(std::exception の仮想 public メンバー関数) [編集]
[virtual]
説明文字列を返す
(std::exception の仮想 public メンバー関数) [編集]

[編集] 関連項目

ローカル時刻が存在しないことを報告するためにスローされる例外
(クラス) [編集]
English 日本語 中文(简体) 中文(繁體)