私はライブラリboost::variant
を使用して多数の型を保存しています。タイプの数が増えているので、すぐに20種類の制限に達します。ドキュメントでは、mpl::vector
を使用してバリアントを定義することができます.20種類以上のタイプが可能です(正しい場合は50まで)。私はこのようなバリアント定義を置き換えようとしました:mpl :: vectorを使用してboost :: variant型を定義する
#include <boost/variant.hpp>
#include <boost/mpl/vector.hpp>
typedef boost::mpl::vector<
float,
math::float2,
math::float3,
relative_point<1>,
relative_point<2>,
relative_point<3>,
std::string,
color,
group,
dictionnary,
reference,
line,
strip,
text,
font
> variant_mpl_vec;
typedef boost::make_variant_over<variant_mpl_vec>::type data_type;
// This is the old definition
/*typedef boost::variant<
float,
math::float2,
math::float3,
relative_point<1>,
relative_point<2>,
relative_point<3>,
std::string,
color,
group,
dictionnary,
reference,
line,
strip,
text,
font
> data_type;*/
私は自分のコードを直接入れています。ほとんどの型は非常に少ないデータを含む構造体です。
error: no matching function for call to ‘boost::detail::variant::make_initializer_node::apply<boost::mpl::pair< ... and lots more ...
前バリアントの定義がうまく働いていたので、私は私の交換は動作しません驚いている:コンパイルする場合
は、私は奇妙です。私はmpl
を初めて使っているので、何かが足りなくなっているかもしれませんが、何が見つかりません!いいですか?
ありがとうございます。
ものの簡易版で、問題の コードが 上でコンパイルすることができ[ideone](HTTP:/ /ideone.com/Sgx02) この[document](http://www.boost.org/doc/libs/1_47_0/doc/html/variant/tutorial.html#variant.tutorial.over-sequence) によれば、 : いくつかのコンパイラで標準適合の問題のために、 'make_variant_over' これらのコンパイラでは、ライブラリは、 ' BOOSのプリプロセッサシンボルの定義を介して、 T_VARIANT_NO_TYPE_SEQUENCE_SUPPORT'._ 私は 'BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT'の値をチェックすることをお勧めします。 –
問題が解決しました。これはバリアントの定義のせいで問題ではないようですが、バリアントを入力として 'boost :: variant'とする汎用関数です。この関数は 'T0'を' boost :: detail :: variant :: over_sequence > 'と見ます。 –
neodelphi