私は bencode をデコードしており、gcc 4.4 でうまく動作するコードがいくつかあります。しかし、最近 gcc 4.6 にアップグレードしたため、このコードはビルドされなくなりました。
#ifndef BENCODE_VALUETYPES_H
#define BENCODE_VALUETYPES_H
#include <boost/variant.hpp>
#include <string>
#include <vector>
#include <map>
namespace bencode {
typedef boost::make_recursive_variant<
int,
std::string,
std::vector<boost::recursive_variant_>,
std::map<std::string, boost::recursive_variant_> >::type Value;
typedef std::map<std::string, Value> ValueDictionary;
typedef std::vector<Value> ValueVector;
};
#endif
g++ には次のエラー メッセージが表示されます。
/usr/include/c++/4.6/bits/stl_pair.h: In instantiation of 'std::pair<const std::basic_string<char>, boost::recursive_variant_>':
Decoder.cpp:97:39: instantiated from here
/usr/include/c++/4.6/bits/stl_pair.h:93:11: error: 'std::pair<_T1, _T2>::second' has incomplete type
/usr/include/boost/variant/variant_fwd.hpp:232:12: error: forward declaration of 'struct boost::recursive_variant_'
最新のブースト バージョン (現時点では 1.48)のドキュメントには、「いくつかのコンパイラでの標準準拠の問題により、make_recursive_variant は広くサポートされていません」と記載されており、代わりに recursive_wrapper を使用する必要があります。しかし、私は変更を行うのに問題があります.ラッパーを使用してこれがどのように見えるべきか知っている人はいますか?