[過去ログ]
C++相談室 part164 (1002レス)
C++相談室 part164 http://mevius.5ch.net/test/read.cgi/tech/1683600652/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
608: デフォルトの名無しさん (ワッチョイ 2301-9pon) [sage] 2023/07/30(日) 23:32:06.49 ID:Phugis3j0 初期化していないstd::optional <int>をdereferenceすると0として扱われます boost::optional <int>だとAbortされるのですが なぜstdではこのようになっているのかどなたかご存知ですか? $ cat test.cpp #include <optional> #include <boost/optional.hpp> #include <iostream> using namespace std; int main () { std::optional <int> i0; cout << *i0 << '\n'; if (i0) cout << "Initilized\n"; else cout << "Not initilized\n"; boost::optional <int> i1; cout << *i1 << '\n'; return 0; } $ ./test 0 Not initilized test: /usr/include/boost/optional/optional.hpp:1212: boost::optional<T>::reference_type boost::optional<T>::get() [with T = int; reference_type = int&]: Assertion `this->is_initialized()' failed. Aborted (core dumped) http://mevius.5ch.net/test/read.cgi/tech/1683600652/608
610: デフォルトの名無しさん (ワッチョイ 2301-9pon) [sage] 2023/07/30(日) 23:58:13.09 ID:Phugis3j0 boostの方が親切ですよね 何でstdでなくしたんでしょ? http://mevius.5ch.net/test/read.cgi/tech/1683600652/610
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.037s