c++ - 无法在 boost 1.57 中编译 boost/any_iterator.hpp

标签 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
          , class Traversal
          , class Reference
          , class Difference
          , class Buffer
        >
        class postfix_increment_proxy<
                    range_detail::any_iterator< // line 131
                        Value
                      , Traversal
                      , Reference
                      , Difference
                      , Buffer
                    >
                >
        {
            // ...
        };

同一文件中还有另一个类遵循相同的模式并生成相同的错误。 range_detail::any_iterator 在文件中稍高一点的前向声明:

namespace range_detail
{
   // ...
   template<
                class Value
              , class Traversal
              , class Reference
              , class Difference
              , class Buffer = any_iterator_default_buffer
            >
            class any_iterator;
    // ...
}

就其值(value)而言,这是我从 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

有人知道解决方法吗?

最佳答案

这似乎是 boost 代码库中的错误。 postfix_increment_proxywritable_postfix_increment_proxy 都在 boost::iterators::detail 命名空间 (iterator_facade.hpp) 中。但是,这两个名称在 any_iterator.hpp 中都是不合格的。在两个名称前添加 boost::iterators::detail:: 允许代码编译。

对于那些不喜欢编辑 boost 代码的人来说,包括 iterator_facade.hpp 之后是 using namespace boost::iterators::detail 之后是 any_iterator.hpp 的 include 也可以解决问题以命名空间污染为代价。 VS2012 不支持它们,所以它对我没有任何好处,但你也可以使用 C++11。

提交的工单: https://svn.boost.org/trac/boost/ticket/10754

关于c++ - 无法在 boost 1.57 中编译 boost/any_iterator.hpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26759817/

相关文章:

c - 下标值的错误既不是数组也不是指针也不是 vector

c++ - 增加 map 中的值

c++ - 哪个算法需要 "visitor"(boost 库中的术语)?

c++ - 嵌套 `static_for` 导致编译器错误

c++ - Boost 版本在 Ubuntu Trusty 上至少为 1.56

c++ - 使用 Boost ptree 解析 std::string

C++ - 3个类之间的循环依赖

c++ - 'tesseract/baseapi.h' 错误

c++ - 来自指向派生类的指针的 `static_cast<Base*>(static_cast<void*>(derived))` 何时有效?

c++ - 光线追踪程序中的全向光给出了错误的渲染 C++