开发者

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). 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(PDCUTestM开发者_StackOverflowessage, 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?


As I remember, template parsing is just awkward in 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;
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜