構造体を作成しました
struct Event
{
int key;
boost::variant<int, float> value;
};
次のようにイベントを作成することは可能ですか:
Event e;
これを試しましたが、コンパイラ エラーが発生します。これは可能ですか、それともしなければなりませんか:
Event e = new Event();
*編集: *これは、取得しているエラーです: エラー C2061: 構文エラー: 識別子 'storage_' (variant.hpp 内)
ここに variant.hpp にいくつかのコメントがありますが、「最初にバインドされた型が int であるため、意味がわかりません。???
// NOTE TO USER : // Compile error from here indicates that the first bound // type is not default-constructible, and so variant cannot // support its own default-construction. //