VC6 上使用 Boost 1.34.1 的 boost 类中出现错误 C2039
一些历史: 我本来想对 ASIO 使用 boost,但后来发现 ASIO 不能与 VC++ 6.0 一起工作(这是一个要求)。在合并 boost 时,我发现了 Multi_Index_Container 和 Signals 的用途。发现ASIO不兼容后,我将boost降级到1.34.1版本,这样就可以支持VC6了。现在我正在尝试解决所有其他编译错误。
起初,我有这个代码和错误: 我正在尝试使用 build 1.34.1 中的 Boost Multi_Index 来设置 结构体的集合。这个多索引容器将有 2 个唯一的键 (ID 和姓名),因为我必须能够使用任一键进行搜索。我 对 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_traits,所以它必须是 multi_index 正在使用它。这是错误和位置:
C2039: 'access_traits': is not a member of 'tuples'
line 106 in lambda_traits:
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 };
有人知道如何克服这个最新错误吗?
Some history:
I originally wanted to use boost for ASIO, but then found that ASIO won't work with VC++ 6.0 (which is a requirement). While incorporating boost, I found use for Multi_Index_Container and Signals. Aftering finding that ASIO was not compatible, I downgraded boost to version 1.34.1 so that it would support VC6. Now I'm trying to iron out all of the other compile errors.
At first, I had this code and error:
I am trying to use Boost Multi_Index from build 1.34.1 to set up a
collection of structs. This Multi Index container will have 2 unique keys
(ID and Name), since I have to be able to search it with either key. I
made the compiler-specific corrections for VC++ 6.0 SP5:
boost::multi_index::multi_index_container
member_offset<A,int,offsetof(A,x)>
My complete declaration is:
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;
Later, I attempt to set up indicies for both of these keys, according to
VC++ 6.0 compiler-specific syntax to bypass the Get/Tag issue:
typedef index<PDCUMessageList, ID>::type IDIndex;
typedef index<PDCUMessageList, Name>::type NameIndex;
using the above code, I got the following error:
error C2039: 'type': is not a member of "global namespace" referencing the two typedef lines above.
This issue I fixed by clarifying the namespaces:
typedef boost::multi_index::index<PDCUMessageList, ID>::type IDIndex;
typedef boost::multi_index::index<PDCUMessageList, Name>::type NameIndex;
Now I've got another error occuring in one of the boost classes:
lambda_traits.hpp. I'm not explicitly using lambda_traits, so it must be
multi_index that is using it. Here's the error and location:
C2039: 'access_traits': is not a member of 'tuples'
line 106 in lambda_traits:
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 };
Anyone have any ideas how to get past this latest error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我记得,模板解析在 VC6 中很尴尬。
尝试尽可能地简化依赖类型。例如:
As I remember, template parsing is just awkward in VC6.
Try to simplify dependent types as much as you can. For example: