問題タブ [std-variant]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - std::variant は boost::variant<>::types と同様の機能を提供しますか?
boost::variant
boost::variant<>::types
は、で便利に使用できるを介してバリアント型のリストを公開しboost::mpl::for_each
ます。std::variant
そんなメンバーがいない。
提供されているようstd::variant_alternative
です。boost::mpl::for_each
これを使用して、取り込み可能な型リストを作成できますか? それとも、別の反復戦略を可能にしますか?
c++ - void* データが含まれている場合、 std::variant のデストラクタは何をしますか
プロジェクトで使い始めたばかりstd::variant
です。私は疑問を持っています。std::variant
以下に示すコードで、 のデストラクタは何をしますか。Variant はvoid*
データを保持します。void*
バリアントが範囲外になると、ポインターが指していた実際のオブジェクトではなく、メモリのみが解放されると思います。したがって、この場合、メモリ リークが発生します。私の理解が正しいかどうか知りたいです。