boost::spirit::qi ルールを定義しました。
boost::spirit::qi::rule<Iterator, Identifier()> id;
ここで、識別子は次のように定義されます。
BOOST_STRONG_TYPEDEF(std::string, Identifier)
しかし、私が使用するとき
BOOST_SPIRIT_DEBUG_NODE(id);
次のエラーでコンパイルに失敗します。
boost_1_51_0/boost/spirit/home/support/attributes.hpp:1203: error: no match for 'operator<<' in 'out << val'
そして、ostream のオーバーロードされた演算子をリストします。
BOOST_STRONG_TYPEDEF が元の型へのキャスト演算子を定義していることを知っているので、コンパイラは Identifier から std::string に暗黙的にキャストすべきではありませんoperator<<
か? または、コンパイラが他の演算子 (つまり ) と一致させようとしているときに、型のキャスト演算子を適用できないようにする制限はありoperator<<
ますか?
次の演算子を定義すると、コンパイルされます。
inline std::ostream& operator<<(std::ostream& os, const Identifier& id)
{
return os << static_cast<std::string const&>(id);
}
私はgcc4.4.2を使用しています