[gil] Compilation errors with MSVC10

Hi there, there seems to be some problems with the new MSVC10 compiler and bit_aligned images in gil. The following was compiling fine before I started using MSVC10. Here is some sample code: #include <vector> #include <algorithm> #include <boost/gil/gil_all.hpp> using namespace std; using namespace boost; using namespace boost::gil; int main(int argc, char* argv[]) { typedef bit_aligned_image1_type< 1, gray_layout_t >::type image_t; typedef image_t::view_t view_t; typedef view_t::reference pixel_t; typedef vector< unsigned char > buffer_t; typedef bit_aligned_pixel_iterator< pixel_t > it_t; vector< unsigned char > buf; it_t begin = it_t( &buf.front(), 0 ); it_t end = it_t( &buf.front(), 0 ); image_t img; image_t::view_t v = view( img ); std::copy( begin , end , v.row_begin( 0 ) ); return 0; } The error message is: c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2216): error C2665: 'std::_Copy_impl' : none of the 2 overloads could convert all the argument types Anyone, any idea? I'll keep investigating. Regards, Christian

Hi there again, a bit more information. MSVC10 is complaining about that it cannot find the correct copy algorithm implementation since for some reason the iterator categories are messed up in its opinion. I doubt that. Here is why: Copy takes an input and output interator type. My input type is: bit_aligned_pixel_iterator< const pixel_t >. The output is: bit_aligned_pixel_iterator< pixel_t >. Obviously the iterator category for both types is the same and when asked for it results into: boost::detail::iterator_category_with_traversal<std::input_iterator_tag,boost::random_access_traversal_tag>. Now when calling copy the compiler eventually has to decide what copy implementation to use based on the iterator categories. For reasons I don't understand right now it cannot choose between: _OutIt std::_Copy_impl<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::input_iterator_tag,std::output_iterator_tag) _OutIt std::_Copy_impl<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::random_access_iterator_tag,std::random_access_iterator_tag) I would think the second one is the one to go with. I'm pretty sure this behavior is new with MSVC10 and I cannot recall this problem with older MSVCs. Unfortunately I don't have access to older versions right now. Anyone can help me out here? Here some simple test code: #include <vector> #include <algorithm> #include <boost/gil/gil_all.hpp> using namespace std; using namespace boost; using namespace boost::gil; int main(int argc, char* argv[]) { typedef bit_aligned_image1_type< 1, gray_layout_t >::type image_t; typedef image_t::view_t view_t; typedef view_t::reference pixel_t; typedef vector< unsigned char > buffer_t; typedef bit_aligned_pixel_iterator< pixel_t > it_t; image_t img( 10, 10 ); image_t::view_t v = view( img ); vector< unsigned char > buf( 100 ); it_t begin = it_t( &buf.front(), 0 ); it_t end = it_t( &buf.front(), 0 ); typedef view_t::x_iterator x_it_t; x_it_t it = v.row_begin( 0 ); std::copy( begin, end, it ); return 0; } Thanks, Christian

Hi there, it seems I'm not the only having issues. I found a thread online and it helped me overcome the problem by setting #define _HAS_ITERATOR_DEBUGGING 0 in front of my code. As it turns out release configuration works fine but debug is failing. It could be a general problem with boost::iterator_facade from my standpoint. Now this is not a workaround I would like to add to my boost submission of the new gil::io. Anyone having more insight? Thanks, Christian PS: Here the link to the thread explaining a similar problem to mine: http://old.nabble.com/-repost--multiarray--Bug-with-boost::detail::multi_arr...

2010/5/30 Christian Henning <chhenning@gmail.com>:
Hi there, it seems I'm not the only having issues. I found a thread online and it helped me overcome the problem by setting
#define _HAS_ITERATOR_DEBUGGING 0
in front of my code. As it turns out release configuration works fine but debug is failing. It could be a general problem with boost::iterator_facade from my standpoint.
Now this is not a workaround I would like to add to my boost submission of the new gil::io. Anyone having more insight?
Thanks, Christian
PS: Here the link to the thread explaining a similar problem to mine:
http://old.nabble.com/-repost--multiarray--Bug-with-boost::detail::multi_arr... _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Christian, unfortunately not more insight, but I just tested your code sample with MSVC8 (aka VS2005) and MSVC9 (aka VS2008) and it compiles in both cases with no errors. However, I get the following warning: warning C4996: 'std::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(2550) : see declaration of 'std::copy' Hope that helps Peter
participants (2)
-
Christian Henning
-
Peter Goetz