2011-10-26から1日間の記事一覧

boost::variantの値をクリアする

C++

Boost.VariantにはNever Empty保証という考え方があり、一度値を入れてしまうと、他の値を入れることはできてもクリアすることはできません。 #include <iostream> #include <string> #include <boost/variant.hpp> int main() { boost::variant<int, std::string, double> v; // デフォルトコンストラクトはできる v = 3; //</int,></boost/variant.hpp></string></iostream>…