
Hi, I've been toying around with the idea of using fusion in my geometry library (at least that seems to be the terminology in use around here). I started reading the documentation and I ran into a problem with the firs thing I tried to do. #include <boost/array.hpp> #include <boost/fusion/iterator.hpp> #include <boost/fusion/sequence.hpp> #include <iostream> int main() { namespace fusion = boost::fusion; boost::array<float,3> position = { {0.f, 1.f, 2.f} }; std::cout << deref( fusion::begin(position) ) << std::endl; return 0; } fails to compile with: ------------------------------------------------------ main.cpp c:\code\boost-head\boost\boost\fusion\sequence\adapted\array\array_iterator.hpp(62) : error C2676: binary '[' : 'boost::array<T,N>' does not define this operator or a conversion to a type acceptable to the predefined operator with [ T=float, N=3 ] c:\code\boost-head\boost\boost\fusion\sequence\adapted\array\array_iterator.hpp(61) : while compiling class template member function 'float &boost::fusion::array_iterator<Array,Pos>::deref<Iterator>::call(const Iterator &)' with [ Array=boost::array<float,3>, Pos=0, Iterator=boost::fusion::array_iterator<boost::array<float,3>,0> ] c:\code\boost-head\boost\boost\fusion\iterator\deref.hpp(35) : see reference to class template instantiation 'boost::fusion::array_iterator<Array,Pos>::deref<Iterator>' being compiled with [ Array=boost::array<float,3>, Pos=0, Iterator=boost::fusion::array_iterator<boost::array<float,3>,0> ] c:\code\boost-head\boost\boost\fusion\iterator\deref.hpp(54) : see reference to class template instantiation 'boost::fusion::extension::deref_impl<boost::fusion::iterator_facade_tag>::apply<Iterator>' being compiled with [ Iterator=boost::fusion::array_iterator<boost::array<float,3>,0> ] c:\code\geometry\source\main.cpp(95) : see reference to class template instantiation 'boost::fusion::result_of::deref<Iterator>' being compiled with [ Iterator=boost::fusion::array_iterator<boost::array<float,3>,0> ] ------------------------------------------------------ changing deref::call from: return it.array[Iterator::index::value]; to: return it.array.at( Iterator::index::value ); causes it to compile so I'm thinking it is a compiler bug that needs to be worked around.

Michael Marcin wrote:
[...]
fails to compile with:
[...]
It is indeed a compiler bug, but I think there's more to it than that. With your fix, VC7.1 complains: boost\array.hpp(159) : error C3861: 'size': identifier not found, even with argument-dependent lookup while VC8 is ok. This is not a problem on any other compiler though. Also, it's funny that the fusion test for array is also ok. I noted that the thing that's causing problems is the header include: #include <boost/array.hpp> #include <boost/fusion/iterator.hpp> #include <boost/fusion/sequence.hpp> Changing this to #include <boost/array.hpp> #include <boost/fusion/sequence/adapted/array.hpp> #include <boost/fusion/sequence/intrinsic.hpp> makes VC++ happy. I'll investigate further... Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

Joel de Guzman wrote:
Michael Marcin wrote:
Alright. It is a compiler bug indeed. I traced it down to the operators! (of all things!). I just submitted a workaround for VC++. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
participants (2)
-
Joel de Guzman
-
Michael Marcin