我正在构建可以在 OS X 10.8.5 上使用 Xcode 4.x、Qt 5.0.1 构建良好的代码,但我刚刚升级了 Xcode 和 Qt,并且在拉入 Qt 标头时我无法再构建任何东西。
问题是 QtSharedPointer 类使用 std::forward 但据我所知,OS X 10.8.5/Xcode 5.0 仍然不支持 std::forward。它没有在随附的标准库中的任何地方定义,因此,当我尝试构建时,我收到此错误:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/QAction:1:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/qaction.h:47:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:49:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qpalette.h:47:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qbrush.h:53:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qpixmap.h:49:
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtCore.framework/Headers/qsharedpointer.h:50:
.../Qt5.1.1/5.1.1/clang_64/lib/QtCore.framework/Headers/qsharedpointer_impl.h:411:36: error: no template named 'forward' in namespace 'std'; did you mean 'boost::forward'?
new (result.data()) T(std::forward<Args>(arguments)...);
~~~~~^~~~~~~
boost::forward
/usr/local/include/boost/move/utility.hpp:176:21: note: 'boost::forward' declared here
inline T&& forward(U&& t
^
我确实注意到 QtSharedPointer 标题顶部的这些行:
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
# include <utility> // for std::forward
#endif
但在下面(第 411 行),它只使用 std::forward 而不检查是否定义了这些宏
// now initialize the data
new (result.data()) T(std::forward<Args>(arguments)...);
这些宏实际上是未定义的,因此,我最初强制包含实用程序,但由于我后来发现 std::forward 不在那里,它没有帮助。
这似乎是一个 Qt 错误,我打算将它提交到那里,但有没有人想出一个解决方法?