C++ Can';t在boost 1.57中编译boost/any_iterator.hpp

C++ Can';t在boost 1.57中编译boost/any_iterator.hpp,c++,boost,compiler-errors,C++,Boost,Compiler Errors,在(尝试)升级VS2012项目以使用boost 1.57之后,我再也无法编译了--boost/any_iterator.hpp(见下文)中会出现大量错误消息。作为测试,我创建了一个新项目,其中只包含一个空的主函数和#include“boost/any_iterator.hpp”,并得到了相同的错误集。以下是它抱怨的代码: // snippet from boost/any_iterator.hpp template< class Value ,

在(尝试)升级VS2012项目以使用boost 1.57之后,我再也无法编译了--
boost/any_iterator.hpp
(见下文)中会出现大量错误消息。作为测试,我创建了一个新项目,其中只包含一个空的主函数和
#include“boost/any_iterator.hpp”
,并得到了相同的错误集。以下是它抱怨的代码:

// snippet from boost/any_iterator.hpp

template<
            class Value
          , class Traversal
          , class Reference
          , class Difference
          , class Buffer
        >
        class postfix_increment_proxy<
                    range_detail::any_iterator< // line 131
                        Value
                      , Traversal
                      , Reference
                      , Difference
                      , Buffer
                    >
                >
        {
            // ...
        };
值得一提的是,以下是我从VS2012中得到的一组错误:

Error   1   error C2143: syntax error : missing ';' before '<'  [path]\boost\range\detail\any_iterator.hpp  131
Error   2   error C2059: syntax error : '<' [path]\boost\range\detail\any_iterator.hpp  131
Error   3   error C2065: 'Value' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  134
Error   4   error C2065: 'Traversal' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  135
Error   5   error C2065: 'Reference' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  136
Error   6   error C2065: 'Difference' : undeclared identifier   [path]\boost\range\detail\any_iterator.hpp  137
Error   7   error C2065: 'Buffer' : undeclared identifier   [path]\boost\range\detail\any_iterator.hpp  138
Error   8   error C2923: 'boost::range_detail::any_iterator' : 'Value' is not a valid template type argument for parameter 'Value'  [path]\boost\range\detail\any_iterator.hpp  138
Error   9   error C2923: 'boost::range_detail::any_iterator' : 'Traversal' is not a valid template type argument for parameter 'Traversal'  [path]\boost\range\detail\any_iterator.hpp  138
Error   10  error C2923: 'boost::range_detail::any_iterator' : 'Reference' is not a valid template type argument for parameter 'Reference'  [path]\boost\range\detail\any_iterator.hpp  138
Error   11  error C2923: 'boost::range_detail::any_iterator' : 'Difference' is not a valid template type argument for parameter 'Difference'    [path]\boost\range\detail\any_iterator.hpp  138
Error   12  error C2923: 'boost::range_detail::any_iterator' : 'Buffer' is not a valid template type argument for parameter 'Buffer'    [path]\boost\range\detail\any_iterator.hpp  138
Error   13  error C2143: syntax error : missing ';' before '{'  [path]\boost\range\detail\any_iterator.hpp  140
Error   14  error C2447: '{' : missing function header (old-style formal list?) [path]\boost\range\detail\any_iterator.hpp  140

错误1错误C2143:语法错误:缺少“;”在“之前,这似乎是boost代码库中的一个bug
postfix\u increment\u proxy
writable\u postfix\u increment\u proxy
都位于
boost::iterators::detail
命名空间(iterator\u facade.hpp)中。但是,这两个名称在任何_iterator.hpp中都是非限定的。在两个名称前面添加
boost::iterators::detail::
可以编译代码

对于那些对编辑boost代码感到不舒服的人,包括迭代器_facade.hpp,然后使用命名空间boost::iterators::detail
,然后使用任何迭代器的include.hpp,也会以命名空间污染为代价来解决这个问题。VS2012不支持它们,所以它对我没有任何好处,但您也可以使用C++11

提交的票证:

这只是
postfix\u increment\u proxy
的部分特化,因为
T
是any
any\u迭代器类型。这看起来很复杂,因为
任何迭代器都是以5个东西为模板的,您必须复制所有这些东西来进行专门化,但是代码的这一部分看起来非常好。“我不知道它为什么不编译tho!”巴里明白了;我错过了迭代器&u facade.hpp先前声明的
模板postix\u increment\u proxy
,因此我无法找出
t
的来源。(问题编辑)这实际上似乎让我找到了答案--
postfix\u increment\u proxy
boost::iterators::detail
命名空间中,但它在
任何迭代器.hpp
中的用法(其类不在该命名空间中)是不合格的。很高兴我能帮助您完全靠自己解决:)我认为所描述的解决方法不准确。它可能适用于MSVC,但这只是因为专业化逻辑被破坏了。修复方法是专门化命名空间
boost::iterators::detail
中的类,而不是
boost::detail
Error   1   error C2143: syntax error : missing ';' before '<'  [path]\boost\range\detail\any_iterator.hpp  131
Error   2   error C2059: syntax error : '<' [path]\boost\range\detail\any_iterator.hpp  131
Error   3   error C2065: 'Value' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  134
Error   4   error C2065: 'Traversal' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  135
Error   5   error C2065: 'Reference' : undeclared identifier    [path]\boost\range\detail\any_iterator.hpp  136
Error   6   error C2065: 'Difference' : undeclared identifier   [path]\boost\range\detail\any_iterator.hpp  137
Error   7   error C2065: 'Buffer' : undeclared identifier   [path]\boost\range\detail\any_iterator.hpp  138
Error   8   error C2923: 'boost::range_detail::any_iterator' : 'Value' is not a valid template type argument for parameter 'Value'  [path]\boost\range\detail\any_iterator.hpp  138
Error   9   error C2923: 'boost::range_detail::any_iterator' : 'Traversal' is not a valid template type argument for parameter 'Traversal'  [path]\boost\range\detail\any_iterator.hpp  138
Error   10  error C2923: 'boost::range_detail::any_iterator' : 'Reference' is not a valid template type argument for parameter 'Reference'  [path]\boost\range\detail\any_iterator.hpp  138
Error   11  error C2923: 'boost::range_detail::any_iterator' : 'Difference' is not a valid template type argument for parameter 'Difference'    [path]\boost\range\detail\any_iterator.hpp  138
Error   12  error C2923: 'boost::range_detail::any_iterator' : 'Buffer' is not a valid template type argument for parameter 'Buffer'    [path]\boost\range\detail\any_iterator.hpp  138
Error   13  error C2143: syntax error : missing ';' before '{'  [path]\boost\range\detail\any_iterator.hpp  140
Error   14  error C2447: '{' : missing function header (old-style formal list?) [path]\boost\range\detail\any_iterator.hpp  140