Boost C++ Libraries: Ticket #1133: compile error for parsing a string on vc2005 https://svn.boost.org/trac10/ticket/1133 <pre class="wiki">#include &lt;string&gt; #include &lt;boost/spirit/core.hpp&gt; extern std::string s; extern boost::spirit::rule&lt;&gt; r; void compile_failed() { boost::spirit::parse(s.begin(), s.end(), r); } /**/ </pre><p> This is the error message the compiler reported: </p> <pre class="wiki">1&gt;parse.cpp 1&gt;c:\documents and settings\yangbo\桌面\work\research\boost\boost\spirit\core\non_terminal\impl\rule.ipp(190) : error C2664: “boost::spirit::impl::abstract_parser&lt;ScannerT,AttrT&gt;::do_parse_virtual”: 不能将参数 1 从“const boost::spirit::scanner&lt;IteratorT,PoliciesT&gt;”转换为“const boost::spirit::scanner&lt;&gt; &amp;” 1&gt; with 1&gt; [ 1&gt; ScannerT=boost::spirit::scanner&lt;&gt;, 1&gt; AttrT=boost::spirit::nil_t 1&gt; ] 1&gt; and 1&gt; [ 1&gt; IteratorT=std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;, 1&gt; PoliciesT=boost::spirit::scanner_policies&lt;&gt; 1&gt; ] 1&gt; 原因如下: 无法从“const boost::spirit::scanner&lt;IteratorT,PoliciesT&gt;”转换为“const boost::spirit::scanner&lt;&gt;” 1&gt; with 1&gt; [ 1&gt; IteratorT=std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;, 1&gt; PoliciesT=boost::spirit::scanner_policies&lt;&gt; 1&gt; ] 1&gt; 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符 1&gt; c:\documents and settings\yangbo\桌面\work\research\boost\boost\spirit\core\non_terminal\impl\rule.ipp(172): 参见对正在编译的函数 模板 实例化“boost::spirit::match&lt;boost::spirit::nil_t&gt; boost::spirit::impl::rule_base&lt;DerivedT,EmbedT,T0,T1,T2&gt;::parse_main&lt;ScannerT&gt;(const ScannerT &amp;) const”的引用 1&gt; with 1&gt; [ 1&gt; DerivedT=boost::spirit::rule&lt;&gt;, 1&gt; EmbedT=const boost::spirit::rule&lt;&gt; &amp;, 1&gt; T0=boost::spirit::nil_t, 1&gt; T1=boost::spirit::nil_t, 1&gt; T2=boost::spirit::nil_t, 1&gt; ScannerT=boost::spirit::scanner&lt;std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,boost::spirit::scanner_policies&lt;&gt;&gt; 1&gt; ] 1&gt; c:\documents and settings\yangbo\桌面\work\research\boost\boost\spirit\core\impl\parser.ipp(28): 参见对正在编译的函数 模板 实例化“boost::spirit::match&lt;boost::spirit::nil_t&gt; boost::spirit::impl::rule_base&lt;DerivedT,EmbedT,T0,T1,T2&gt;::parse&lt;boost::spirit::scanner&lt;IteratorT,PoliciesT&gt;&gt;(const ScannerT &amp;) const”的引用 1&gt; with 1&gt; [ 1&gt; DerivedT=boost::spirit::rule&lt;&gt;, 1&gt; EmbedT=const boost::spirit::rule&lt;&gt; &amp;, 1&gt; T0=boost::spirit::nil_t, 1&gt; T1=boost::spirit::nil_t, 1&gt; T2=boost::spirit::nil_t, 1&gt; IteratorT=std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;, 1&gt; PoliciesT=boost::spirit::scanner_policies&lt;&gt;, 1&gt; ScannerT=boost::spirit::scanner&lt;std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,boost::spirit::scanner_policies&lt;&gt;&gt; 1&gt; ] 1&gt; c:\documents and settings\yangbo\桌面\work\research\http_client\parse.cpp(6): 参见对正在编译的函数 模板 实例化“boost::spirit::parse_info&lt;IteratorT&gt; boost::spirit::parse&lt;std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;,DerivedT&gt;(const IteratorT &amp;,const IteratorT &amp;,const boost::spirit::parser&lt;DerivedT&gt; &amp;)”的引用 1&gt; with 1&gt; [ 1&gt; IteratorT=std::_String_iterator&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;, 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Alloc=std::allocator&lt;char&gt;, 1&gt; DerivedT=boost::spirit::rule&lt;&gt; 1&gt; ] </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1133 Trac 1.4.3 anonymous Tue, 31 Jul 2007 13:47:33 GMT <link>https://svn.boost.org/trac10/ticket/1133#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1133#comment:1</guid> <description> <p> Scanner incompatibility. See "The Scanner and Parsing" section. Try: </p> <p> extern boost::spirit::rule&lt;boost::spirit::scanner&lt;std::string::iterator&gt; &gt; r; </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Tue, 31 Jul 2007 13:48:50 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1133#comment:2 https://svn.boost.org/trac10/ticket/1133#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> This is not a bug. See comment above. </p> Ticket pop.atry@… Wed, 01 Aug 2007 03:44:46 GMT <link>https://svn.boost.org/trac10/ticket/1133#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1133#comment:3</guid> <description> <p> OK, but why does rule need know the iterator type, why not specify the iterator type when parsing? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Wed, 01 Aug 2007 04:05:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1133#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1133#comment:4</guid> <description> <p> The proper forum to discuss these issues is the Spirit mailing list: <a class="ext-link" href="https://lists.sourceforge.net/lists/listinfo/spirit-general"><span class="icon">​</span>https://lists.sourceforge.net/lists/listinfo/spirit-general</a> </p> <p> Anyway, this is also discussed in the docs. IIRC, the FAQ also mentions the reasons. </p> </description> <category>Ticket</category> </item> </channel> </rss>