[英]Error C2039 in boost class with Boost 1.34.1 on VC6
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). 历史:我本来想对ASIO使用boost,但是后来发现ASIO无法在VC ++ 6.0上运行(这是必需的)。 While incorporating boost, I found use for Multi_Index_Container and Signals.
合并boost时,发现可以用于Multi_Index_Container和Signals。 Aftering finding that ASIO was not compatible, I downgraded boost to version 1.34.1 so that it would support VC6.
在发现ASIO不兼容之后,我将Boost降级到1.34.1版本,以便它支持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. 最初,我有以下代码和错误:我试图使用1.34.1版中的Boost Multi_Index来建立结构体集合。 This Multi Index container will have 2 unique keys (ID and Name), since I have to be able to search it with either key.
此多索引容器将具有2个唯一键(ID和名称),因为我必须能够使用任一键进行搜索。 I made the compiler-specific corrections for VC++ 6.0 SP5:
我对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: 后来,我尝试根据VC ++ 6.0编译器特定的语法为这两个键设置索引,以绕过Get / Tag问题:
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. 错误C2039:“类型”:不是引用上述两条typedef行的“全局名称空间”的成员。
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. 现在,在其中一个增强类中发生了另一个错误:lambda_traits.hpp。 I'm not explicitly using lambda_traits, so it must be multi_index that is using it.
我没有明确使用lambda_traits,因此它必须是正在使用它的multi_index。 Here's the error and location:
这是错误和位置:
C2039: 'access_traits': is not a member of 'tuples' C2039:'access_traits':不是'tuples'的成员
line 106 in lambda_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 };
Anyone have any ideas how to get past this latest error? 任何人都有任何想法如何克服这个最新的错误?
As I remember, template parsing is just awkward in VC6. 我记得在VC6中模板解析很尴尬。 Try to simplify dependent types as much as you can.
尝试尽可能您可以简化相关的类型。 For example:
例如:
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;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.