VC6上boost 1.34.1的boost类中出现错误C2039
Error C2039 in boost class with Boost 1.34.1 on VC6
一些历史:我最初想为ASIO使用boost,但后来发现ASIO无法与VC++6.0一起工作(这是一个要求)。在合并boost时,我发现了Multi_Index_Container和Signals的用途。在发现ASIO不兼容后,我将boost降级到1.34.1版本,以便它支持VC6。现在我正试图消除所有其他的编译错误。
起初,我有这样的代码和错误:我正在尝试使用版本1.34.1中的Boost Multi_Index来设置结构的集合。此多索引容器将具有2个唯一密钥(ID和Name),因为我必须能够用任意一个键进行搜索。我对VC++6.0 SP5:进行了编译器特定的更正
boost::multi_index::multi_index_container
member_offset<A,int,offsetof(A,x)>
我的完整声明是:
enum RESPONSE_CODES
{
Pass = 200,
Fail = 201,
Hex = 202,
Decimal = 203,
String = 204,
Help = 205,
None = 255
}
struct PDCUTestMessage
{
string name;
char id;
RESPONSE_CODES responseType;
int numberOfParameters;
string errorString;
vector<char> response;
string param1Name;
string param2Name;
string param3Name;
string param4Name;
string param5Name;
boost::function2<bool, vector<char>, PDCUTestMessage &> process;
// constructors not listed
};
struct ID();
struct Name();
typedef boost::multi_index::multi_index_container<
PDCUTestMessage,
boost::multi_index::ordered_unique<
boost::multi_index::tag<ID>,
boost::multi_index::member_offset<PDCUTestMessage, char, offsetof(PDCUTestMessage, id)> >,
boost::multi_index::ordered_unique<
boost::multi_index::tag<Name>,
boost::multi_index::member_offset<PDCUTestMessage, string, offsetof(PDCUTestMessage, name)> >
>
> PDCUMessageList;
后来,我试图为这两把钥匙设置标记,根据VC++6.0编译器特定语法以绕过Get/Tag问题:
typedef index<PDCUMessageList, ID>::type IDIndex;
typedef index<PDCUMessageList, Name>::type NameIndex;
使用上面的代码,我得到了以下错误:
错误C2039:"type":不是引用上面两行typedef的"全局命名空间"的成员。
我通过澄清名称空间解决了这个问题:
typedef boost::multi_index::index<PDCUMessageList, ID>::type IDIndex;
typedef boost::multi_index::index<PDCUMessageList, Name>::type NameIndex;
现在,我在其中一个boost类中出现了另一个错误:lambda_traits.hpp。我没有明确使用lambda_t,所以它必须是使用它的multi_index。以下是错误和位置:
C2039:"access_traits":不是"元组"的成员
lambda_traits:中的第106行
104 template<int N, class T> struct tuple_element_as_reference {
105 typedef typename
106 boost::tuples::access_traits<
107 typename boost::tuples::element<N, T>::type
108 >::non_const_type type;
109 };
有人知道如何克服这个最新的错误吗?
我记得,模板解析在VC6中很尴尬。尽量简化依赖类型。例如:
template<int N, class T> struct tuple_element_as_reference {
typedef typename boost::tuples::element<N, T>
tuples_element_t;
typedef typename tuples_element_t::type
tuples_element_type_t;
typedef typename boost::tuples::access_traits<
tuples_element_type_t
>
tuples_access_traits_t;
typedef typename tuples_access_traits_t::non_const_type
type;
};
相关文章:
- boost::进程间消息队列引发错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在cygwin中测试新的boost安装时出现cpp错误
- 错误"Could not find Boost"(缺少:上下文标头)
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- 尝试将 boost::stacktrace 添加到 CMake 项目时出现构建错误
- 在 boost::qi 中使用过多的替代运算符会导致分段错误
- 使用boost::multiprecision cpp_int左移时出现超时错误
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- 在其他容器中使用 boost::container::static_vector 时,GCC 编译错误"将'const s'绑定到类型's&'的引用丢弃限定符"
- boost::interprocess::file_lock 与 std::ostream 一起使用时的错误行为
- 造成致命错误:boost/fusion/iterator/equal_to.hpp 没有这样的文件或目录
- 在 Centos7 上使用 boost 1.71.0 编译错误
- boost::p rogram_options 在指定意外的位置参数时不报告任何错误
- Boost错误消息
- Boost错误:Boost.文件系统V3及更高版本需要std::wstring支持
- 如何正确地反检查Boost错误代码
- 调试时在has_new_operator.hpp中出现Boost错误
- 哪些Boost.Asio调用返回哪些Boost错误代码/条件