[BGL] [variant] problem (and perhaps solution?) with strong_components.hpp and variant

Hi, it seems the problem is indeed a conflict between the get function of variant.hpp and the get function of two_bit_color_map. After renaming get by getTEST in 1) two_bit_color_map.hpp line 61 2) breadth_first_search.hpp line 78 3) property_map.hpp line 164 the compiling error has disappeared. Of course it is certainly not the right way to fix that bug, maybe wrapping two_bit_color_map get (and alike) function name under some namespace... but I'm not confident enough to take such decision. Maybe there is a better way. Please if someone is more knowledgeable could help me fix that bug. Thanks for your help Nil On Tue, Oct 27, 2009 at 7:31 AM, Nil Geisweiller <ngeiswei@googlemail.com> wrote:
Hi,
I resend that email with the right title header.
---------- Forwarded message ---------- From: Nil Geisweiller <ngeiswei@googlemail.com> Date: Sun, Oct 25, 2009 at 6:11 PM Subject: [Graph] problem with strong_components.hpp and variant To: boost@lists.boost.org
Hi,
it seems there is a conflict between strong_components.hpp and variant, maybe the method boost::get is wrongly overloaded.
The problem occurs with 1.40 but not with 1.37, and it is still occurs with the last svn.
I attach a minimal code to reproduce the bug + compile error
###### test.cpp ######
//uncomment the line below to get the bug #include <boost/graph/strong_components.hpp> #include <boost/variant.hpp>
typedef boost::variant < int, float > intorfloat;
int main() { int i(2); intorfloat iof(i); return boost::get<int>(iof); //problem is here }
########### compile error ###########
a-lin@a-lin-desktop:~/OpenCog/test/bin$ make [100%] Building CXX object CMakeFiles/test.dir/test.cpp.o In file included from /usr/include/boost/graph/graph_concepts.hpp:17, from /usr/include/boost/graph/depth_first_search.hpp:18, from /usr/include/boost/graph/strong_components.hpp:17, from /home/a-lin/OpenCog/test/test.cpp:2: /usr/include/boost/property_map/property_map.hpp: In instantiation of ‘boost::property_traits<int>’: /usr/include/boost/graph/two_bit_color_map.hpp:46: instantiated from ‘boost::two_bit_color_map<int>’ /home/a-lin/OpenCog/test/test.cpp:10: instantiated from here /usr/include/boost/property_map/property_map.hpp:31: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:32: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:33: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:34: error: ‘int’ is not a class, struct, or union type make[2]: *** [CMakeFiles/test.dir/test.cpp.o] Error 1 make[1]: *** [CMakeFiles/test.dir/all] Error 2 make: *** [all] Error 2
Is it a bug? Thanks a lot! Nil

Nil Geisweiller wrote:
Hi,
it seems there is a conflict between strong_components.hpp and variant, maybe the method boost::get is wrongly overloaded.
The problem occurs with 1.40 but not with 1.37, and it is still occurs with the last svn.
I attach a minimal code to reproduce the bug + compile error
###### test.cpp ######
//uncomment the line below to get the bug #include <boost/graph/strong_components.hpp> #include <boost/variant.hpp>
typedef boost::variant < int, float > intorfloat;
int main() { int i(2); intorfloat iof(i); return boost::get<int>(iof); //problem is here }
Works for me :/ MSVC 2008, Vista, Boost 1.40. - Jeff

It is weird, I tried with 2 settings Ubuntu 9.04, gcc-4.3.3, boost 1.40 Ubuntu 9.10, gcc-4.4.1, boost 1.40 And I get the compiling errors: /usr/include/boost/property_map/property_map.hpp: In instantiation of ‘boost::property_traits<int>’: /usr/include/boost/graph/two_bit_color_map.hpp:46: instantiated from ‘boost::two_bit_color_map<int>’ /home/a-lin/Sources/test/test.cpp:10: instantiated from here /usr/include/boost/property_map/property_map.hpp:31: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:32: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:33: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:34: error: ‘int’ is not a class, struct, or union type Has anyone experienced problem too? Thanks Nil On Thu, Oct 29, 2009 at 4:07 PM, Jeffrey Hellrung <jhellrung@ucla.edu> wrote:
Nil Geisweiller wrote:
Hi,
it seems there is a conflict between strong_components.hpp and variant, maybe the method boost::get is wrongly overloaded.
The problem occurs with 1.40 but not with 1.37, and it is still occurs with the last svn.
I attach a minimal code to reproduce the bug + compile error
###### test.cpp ######
//uncomment the line below to get the bug #include <boost/graph/strong_components.hpp> #include <boost/variant.hpp>
typedef boost::variant < int, float > intorfloat;
int main() { int i(2); intorfloat iof(i); return boost::get<int>(iof); //problem is here }
Works for me :/ MSVC 2008, Vista, Boost 1.40.
- Jeff
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Fri, 30 Oct 2009, Nil Geisweiller wrote:
It is weird, I tried with 2 settings
Ubuntu 9.04, gcc-4.3.3, boost 1.40 Ubuntu 9.10, gcc-4.4.1, boost 1.40
And I get the compiling errors:
/usr/include/boost/property_map/property_map.hpp: In instantiation of ‘boost::property_traits<int>’: /usr/include/boost/graph/two_bit_color_map.hpp:46: instantiated from ‘boost::two_bit_color_map<int>’ /home/a-lin/Sources/test/test.cpp:10: instantiated from here /usr/include/boost/property_map/property_map.hpp:31: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:32: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:33: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:34: error: ‘int’ is not a class, struct, or union type
Has anyone experienced problem too?
Thanks Nil
I'm surprised that this did not happen in earlier Boost versions. I think the problem is that two components are using exactly the same function name, and Boost.Graph's version (it's not in strong_components.hpp, just included from there) does not accept the template argument you are giving it. As it appears that there is no member or other function to get the value out of a variant, it might be hard to avoid this error. The version of get() in two_bit_color_map.hpp does not require any explicitly specified template arguments, but that is not the version you want anyway. -- Jeremiah Willcock

On Fri, Oct 30, 2009 at 8:46 AM, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
On Fri, 30 Oct 2009, Nil Geisweiller wrote:
It is weird, I tried with 2 settings
Ubuntu 9.04, gcc-4.3.3, boost 1.40 Ubuntu 9.10, gcc-4.4.1, boost 1.40
And I get the compiling errors:
/usr/include/boost/property_map/property_map.hpp: In instantiation of ‘boost::property_traits<int>’: /usr/include/boost/graph/two_bit_color_map.hpp:46: instantiated from ‘boost::two_bit_color_map<int>’ /home/a-lin/Sources/test/test.cpp:10: instantiated from here /usr/include/boost/property_map/property_map.hpp:31: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:32: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:33: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:34: error: ‘int’ is not a class, struct, or union type
Has anyone experienced problem too?
Thanks Nil
I'm surprised that this did not happen in earlier Boost versions.
yes it does not happen in boost 1.35. I've carefully compared some files from the graph library between 1.35 and 1.40 and I don't see anything suspect added in 1.40. So like you I am really surprised.
I think the problem is that two components are using exactly the same function name, and Boost.Graph's version (it's not in strong_components.hpp, just included from there) does not accept the template argument you are giving it. As it appears that there is no member or other function to get the value out of a variant, it might be hard to avoid this error. The version of get() in two_bit_color_map.hpp does not require any explicitly specified template arguments, but that is not the version you want anyway.
What do you think is the right way to fix that? Thanks Nil

I can confirm I also get this error, both with the minimal test case you provided, and in the real code-base that I'm using/working on at the moment. This is currently preventing me from upgrading to Boost 1.40. John B Nil Geisweiller wrote:
It is weird, I tried with 2 settings
Ubuntu 9.04, gcc-4.3.3, boost 1.40 Ubuntu 9.10, gcc-4.4.1, boost 1.40
And I get the compiling errors:
/usr/include/boost/property_map/property_map.hpp: In instantiation of ‘boost::property_traits<int>’: /usr/include/boost/graph/two_bit_color_map.hpp:46: instantiated from ‘boost::two_bit_color_map<int>’ /home/a-lin/Sources/test/test.cpp:10: instantiated from here /usr/include/boost/property_map/property_map.hpp:31: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:32: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:33: error: ‘int’ is not a class, struct, or union type /usr/include/boost/property_map/property_map.hpp:34: error: ‘int’ is not a class, struct, or union type
Has anyone experienced problem too?
Thanks Nil
On Thu, Oct 29, 2009 at 4:07 PM, Jeffrey Hellrung <jhellrung@ucla.edu> wrote:
Nil Geisweiller wrote:
Hi,
it seems there is a conflict between strong_components.hpp and variant, maybe the method boost::get is wrongly overloaded.
The problem occurs with 1.40 but not with 1.37, and it is still occurs with the last svn.
I attach a minimal code to reproduce the bug + compile error
###### test.cpp ######
//uncomment the line below to get the bug #include <boost/graph/strong_components.hpp> #include <boost/variant.hpp>
typedef boost::variant < int, float > intorfloat;
int main() { int i(2); intorfloat iof(i); return boost::get<int>(iof); //problem is here }
Works for me :/ MSVC 2008, Vista, Boost 1.40.
- Jeff
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (4)
-
Jeffrey Hellrung
-
Jeremiah Willcock
-
John Bartholomew
-
Nil Geisweiller