COIN-OR::LEMON - Graph Library

Opened 15 years ago

Closed 15 years ago

#194 closed defect (fixed)

graph_adaptor_test does not compile with VS2005/2008

Reported by: Alpar Juttner Owned by: Balazs Dezso
Priority: critical Milestone: LEMON 1.1 release
Component: core Version: hg main
Keywords: Cc:
Revision id: b2564598b46d

Description (last modified by Alpar Juttner)

VS2005 reports various errors when compiling test/graph_adaptor_test.cc.

Attachments (1)

a85e7c0769d7.patch (114.9 KB) - added by Balazs Dezso 15 years ago.
Fix for VS2008

Download all attachments as: .zip

Change History (13)

comment:1 Changed 15 years ago by Alpar Juttner

Description: modified (diff)

comment:2 Changed 15 years ago by Peter Kovacs

#67 contains various modifications related to the adaptors and their test file. This problem should be checked again after those changesets were applied.

comment:3 in reply to:  2 ; Changed 15 years ago by Alpar Juttner

Replying to kpeter:

#67 contains various modifications related to the adaptors and their test file. This problem should be checked again after those changesets were applied.

The problem still exists.

(And there are also a huge amount of warnings at the various part of LEMON. This is very annoying.)

comment:4 in reply to:  3 Changed 15 years ago by Alpar Juttner

Replying to alpar:

(And there are also a huge amount of warnings at the various part of LEMON. This is very annoying.)

The patch attached to #208 [94e3cf7b7fb4] solves the problem of warnings.

comment:5 Changed 15 years ago by Alpar Juttner

Summary: graph_adaptor_test does not compile with VS2005graph_adaptor_test does not compile with VS2005/2008

The same problem exists with VS2008, too.

comment:6 Changed 15 years ago by Balazs Dezso

I made a short example which shows the problem with visual c++.

#include <vector> #include <iostream>

template <typename T> struct X {};

template <typename T> struct A {

template <typename S> struct NA {};

};

template <class T> struct B : public A<T> {

template <typename S> struct NB : public X<typename A<T>::template NA<S> > {};

};

If the B did not inherited from the A<T> then the code would be compiled without error. In my opinion the VC++ interprets the template classes when the base classes are already known. I know only one unsafe workaround now.

#ifndef MSVC #define LEMON_FIX_VC(A,B) typename A::template B #else #define LEMON_FIX_VC(A,B) A::B #endif

struct NB : public X<LEMON_FIX_VC(A<T>, NA<S>)> {}; What is your opinion, should we use such workaround?

comment:7 in reply to:  6 Changed 15 years ago by Alpar Juttner

Replying to deba:

Let me just format you code snippets to make it easier to decode:

#include <vector>
#include <iostream>

template <typename T>
struct X {};

template <typename T>
struct A {
        template <typename S>
        struct NA {};
};

template <class T>
struct B : public A<T> {
        template <typename S>
        struct NB : public X<typename A<T>::template NA<S> > {};
};

and

#ifndef MSVC
#define LEMON_FIX_VC(A,B) typename A::template B
#else
#define LEMON_FIX_VC(A,B) A::B
#endif

struct NB : public X<LEMON_FIX_VC(A<T>, NA<S>)> {};

comment:8 in reply to:  6 Changed 15 years ago by Alpar Juttner

Replying to deba:

I know only one unsafe workaround now.

Why is it unsafe?

#define LEMON_FIX_VC(A,B) typename A::template B

Couldn't we find some more meaningful name for this define? E.g. LEMON_WRAP_INHERIT, or something like that.

What is your opinion, should we use such workaround?

Do we have any alternative options?

Changed 15 years ago by Balazs Dezso

Attachment: a85e7c0769d7.patch added

Fix for VS2008

comment:9 Changed 15 years ago by Balazs Dezso

I have uploaded [a85e7c0769d7], which makes a lot of renamings and some improvements in adaptors and edge sets. It also contains the fix wrong scope operator usage in visual c++. The solution is tested under g++ 4.3.2 - linux and MSVC 2008 - windows.

comment:10 in reply to:  9 ; Changed 15 years ago by Alpar Juttner

Replying to deba:

The solution is tested under g++ 4.3.2 - linux and MSVC 2008 - windows.

I've also successfully built it with Intel C++ versions 11.0 and 10.1.

Akos, could you test it with VS2005?

comment:11 in reply to:  10 Changed 15 years ago by Akos Ladanyi

Replying to alpar:

Akos, could you test it with VS2005?

Compiles with VS2005.

comment:12 in reply to:  9 Changed 15 years ago by Alpar Juttner

Resolution: fixed
Status: newclosed

Replying to deba:

I have uploaded [a85e7c0769d7], which makes a lot of renamings and some improvements in adaptors and edge sets. It also contains the fix wrong scope operator usage in visual c++. The solution is tested under g++ 4.3.2 - linux and MSVC 2008 - windows.

The changeset (with changed commit log) is in the main-branch now, see [9b9ffe7d9b75].

Well done!

Note: See TracTickets for help on using tickets.