C++ VC6上boost 1.34.1的boost类中出现错误C2039

C++ VC6上boost 1.34.1的boost类中出现错误C2039,c++,boost,visual-c++-6,C++,Boost,Visual C++ 6,一些历史: 我本来想用boost来实现ASIO,但后来发现ASIO不能与VC++6.0一起工作(这是一项要求)。在合并boost时,我发现了Multi_Index_容器和信号的用法。在发现ASIO不兼容后,我将boost降级为1.34.1版,以便它支持VC6。现在我正试图消除所有其他编译错误 起初,我有以下代码和错误: 我试图使用build 1.34.1中的Boost Multi_Index来建立一个 结构的集合。此多索引容器将具有2个唯一键 (ID和姓名),因为我必须能够用任意一个键搜索它。我

一些历史: 我本来想用boost来实现ASIO,但后来发现ASIO不能与VC++6.0一起工作(这是一项要求)。在合并boost时,我发现了Multi_Index_容器和信号的用法。在发现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)>
boost::多索引::多索引容器
成员单位偏移量
我的完整声明是:

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;
enum响应\u代码
{
通过=200,
失败=201,
十六进制=202,
十进制=203,
字符串=204,
帮助=205,
无=255
}
结构pCuTestMessage
{
字符串名;
字符id;
响应\ U代码响应类型;
int参数;
字符串错误字符串;
媒介反应;
字符串param1Name;
字符串参数名称;
字符串param3Name;
字符串param4Name;
字符串参数名称;
boost::function2过程;
//未列出的构造函数
};
结构ID();
结构名();
typedef boost::multi_index::multi_index_容器<
pCuTestMessage,
boost::多索引::有序唯一<
boost::multi_index::tag,
boost::多索引::成员偏移量>,
boost::多索引::有序唯一<
boost::multi_index::tag,
boost::多索引::成员偏移量>
>
>传播者;
后来,我尝试为这两个键设置标记,根据 绕过Get/Tag问题的VC++6.0编译器特定语法:

typedef index<PDCUMessageList, ID>::type IDIndex;
typedef index<PDCUMessageList, Name>::type NameIndex;
typedef索引::type ididex;
typedef索引::type name索引;
使用上述代码,我得到了以下错误:

错误C2039:“类型”:不是引用上述两行typedef的“全局命名空间”的成员

我通过澄清名称空间解决了这个问题:

typedef boost::multi_index::index<PDCUMessageList, ID>::type IDIndex;
typedef boost::multi_index::index<PDCUMessageList, Name>::type NameIndex;
typedef boost::multi_index::index::type IDIndex;
typedef boost::multi_index::index::type name index;
现在我在一个boost类中发现了另一个错误: lambda_.hpp。我没有明确使用lambda_特征,所以它一定是 正在使用它的多个索引。以下是错误和位置:

C2039:“访问特性”:不是“元组”的成员

lambda_性状中的第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  };
104模板结构元组元素作为引用{
105 typedef typename
106 boost::tuples::access\u特性<
107 typename boost::tuples::element::type
108>::非常量类型;
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;
};
模板结构元组元素作为引用{
typedef typename boost::tuples::element
元组元素;
typedef typename元组\u元素\u t::type
元组元素类型;
typedef typename boost::元组::访问特性<
元组元素类型
>
元组访问特性;
typedef typename元组访问特性:非常量类型
类型
};

不过,我假设原因在我的代码中。错误不可能起源于boost类,因为版本1.34.1已经为VC6编译并测试成功,对吗?我可能不应该改变实际的升压等级…可能。您确定您的ID和名称定义正确吗?我编辑了我的原始帖子,以包含结构pCuTestMessage的代码和作为结构成员的枚举。我很确定我的定义是正确的,但可能最好还是发布它们。你需要升级你的编译器-它甚至不符合C++98。你怎么知道?我在设计环境中指向的VC++目录是VC98和msdev98。据我所知,我是C++98兼容的。我该如何验证呢?VC++6.0在C++98标准定稿一个月后问世,它因使用许多标准前的结构和语法而臭名昭著。VC++的第一个标准支持版本是VC++8.0(尽管7.1至少修复了一些模板的怪异之处)。任何强迫你使用VC++6.0的人都是虐待狂不是一个人在强制要求,而是目标硬件和软件,以及我想要的方法。我是一名政府程序员,为目标系统开发,该系统的配置设置为Windows NT4,无法更改。理想情况下,最终产品是一个升级的可执行文件,可以将其复制到目标硬件上,以代替现有版本,而无需对系统进行额外更改。当前exe是用MFC在VC6中编写的。如果你可以C++洗出另一种方法,在Windows NT4上使用Boost,而不需要额外安装,我会洗耳恭听:O)