Ticket #4517: 4517-missing-std-qualifier-to-ptrdiff_t-in-libs.patch
File 4517-missing-std-qualifier-to-ptrdiff_t-in-libs.patch, 19.8 KB (added by , 10 years ago) |
---|
-
libs/gil/example/interleaved_ptr.hpp
1 1 /* 2 2 Copyright 2005-2007 Adobe Systems Incorporated 3 3 4 4 Use, modification and distribution are subject to the Boost Software License, 5 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 6 http://www.boost.org/LICENSE_1_0.txt). … … 11 11 /*************************************************************************************************/ 12 12 13 13 //////////////////////////////////////////////////////////////////////////////////////// 14 /// \file 14 /// \file 15 15 /// \brief Example on how to create a pixel iterator 16 16 /// \author Lubomir Bourdev and Hailin Jin \n 17 17 /// Adobe Systems Incorporated … … 28 28 #include "interleaved_ref.hpp" 29 29 30 30 namespace boost { namespace gil { 31 32 31 ///////////////////////////////////////////////////////////////////////// 33 32 /// 34 33 /// A model of an interleaved pixel iterator. Contains an iterator to the first channel of the current pixel 35 34 /// 36 /// Models: 35 /// Models: 37 36 /// MutablePixelIteratorConcept 38 37 /// PixelIteratorConcept 39 38 /// boost_concepts::RandomAccessTraversalConcept … … 82 81 // Channels accessor (not required by any concept) 83 82 const ChannelPtr& channels() const { return _channels; } 84 83 ChannelPtr& channels() { return _channels; } 85 84 86 85 // Not required by concepts but useful 87 86 static const std::size_t num_channels = mpl::size<typename Layout::color_space_t>::value; 88 87 private: … … 92 91 93 92 void increment() { _channels+=num_channels; } 94 93 void decrement() { _channels-=num_channels; } 95 void advance( ptrdiff_t d) { _channels+=num_channels*d; }94 void advance(std::ptrdiff_t d) { _channels+=num_channels*d; } 96 95 97 ptrdiff_t distance_to(const interleaved_ptr& it) const { return (it._channels-_channels)/num_channels; }96 std::ptrdiff_t distance_to(const interleaved_ptr& it) const { return (it._channels-_channels)/num_channels; } 98 97 bool equal(const interleaved_ptr& it) const { return _channels==it._channels; } 99 98 100 99 reference dereference() const { return reference(_channels); } … … 110 109 // GIL's planar reference and iterator ("planar_pixel_reference" and "planar_pixel_iterator") which share the class "pixel" as the value_type. The 111 110 // class "pixel" is also the value type for interleaved pixel references. Here we are dealing with channels, not pixels, but the principles still apply. 112 111 template <typename ChannelPtr, typename Layout> 113 struct const_iterator_type<interleaved_ptr<ChannelPtr,Layout> > { 112 struct const_iterator_type<interleaved_ptr<ChannelPtr,Layout> > { 114 113 private: 115 114 typedef typename std::iterator_traits<ChannelPtr>::reference channel_ref_t; 116 115 typedef typename channel_traits<channel_ref_t>::const_pointer channel_const_ptr_t; 117 116 public: 118 typedef interleaved_ptr<channel_const_ptr_t,Layout> type; 117 typedef interleaved_ptr<channel_const_ptr_t,Layout> type; 119 118 }; 120 119 121 120 template <typename ChannelPtr, typename Layout> … … 157 156 ///////////////////////////// 158 157 159 158 template <typename ChannelPtr, typename Layout> 160 inline std::ptrdiff_t memunit_step(const interleaved_ptr<ChannelPtr,Layout>&) { 159 inline std::ptrdiff_t memunit_step(const interleaved_ptr<ChannelPtr,Layout>&) { 161 160 return sizeof(typename std::iterator_traits<ChannelPtr>::value_type)* // size of each channel in bytes 162 161 interleaved_ptr<ChannelPtr,Layout>::num_channels; // times the number of channels 163 162 } 164 163 165 164 template <typename ChannelPtr, typename Layout> 166 inline std::ptrdiff_t memunit_distance(const interleaved_ptr<ChannelPtr,Layout>& p1, const interleaved_ptr<ChannelPtr,Layout>& p2) { 167 return memunit_distance(p1.channels(),p2.channels()); 165 inline std::ptrdiff_t memunit_distance(const interleaved_ptr<ChannelPtr,Layout>& p1, const interleaved_ptr<ChannelPtr,Layout>& p2) { 166 return memunit_distance(p1.channels(),p2.channels()); 168 167 } 169 168 170 169 template <typename ChannelPtr, typename Layout> 171 inline void memunit_advance(interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { 170 inline void memunit_advance(interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { 172 171 memunit_advance(p.channels(), diff); 173 172 } 174 173 … … 194 193 struct dynamic_x_step_type<interleaved_ptr<ChannelPtr,Layout> > { 195 194 typedef memory_based_step_iterator<interleaved_ptr<ChannelPtr,Layout> > type; 196 195 }; 197 198 196 } } // namespace boost::gil 199 197 200 #endif 198 #endif 199 No newline at end of file -
libs/gil/example/mandelbrot.cpp
1 1 /* 2 2 Copyright 2005-2007 Adobe Systems Incorporated 3 3 4 4 Use, modification and distribution are subject to the Boost Software License, 5 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 6 http://www.boost.org/LICENSE_1_0.txt). … … 24 24 // Models a Unary Function 25 25 template <typename P> // Models PixelValueConcept 26 26 struct mandelbrot_fn { 27 typedef point2< ptrdiff_t> point_t;27 typedef point2<std::ptrdiff_t> point_t; 28 28 29 29 typedef mandelbrot_fn const_t; 30 30 typedef P value_type; … … 79 79 jpeg_write_view("out-mandelbrot.jpg",mandel); 80 80 81 81 return 0; 82 } 83 82 } 83 No newline at end of file -
libs/gil/io/test/bmp_old_test.cpp
17 17 18 18 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 19 19 { 20 point2< ptrdiff_t > dim = bmp_read_dimensions( bmp_filename );20 point2< std::ptrdiff_t > dim = bmp_read_dimensions( bmp_filename ); 21 21 22 22 BOOST_CHECK_EQUAL( dim.x, 1000 ); 23 23 BOOST_CHECK_EQUAL( dim.y, 600 ); -
libs/gil/io/test/jpeg_old_test.cpp
17 17 18 18 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 19 19 { 20 point2< ptrdiff_t > dim = jpeg_read_dimensions( jpeg_filename );20 point2< std::ptrdiff_t > dim = jpeg_read_dimensions( jpeg_filename ); 21 21 22 22 BOOST_CHECK_EQUAL( dim.x, 1000 ); 23 23 BOOST_CHECK_EQUAL( dim.y, 600 ); -
libs/gil/io/test/mandel_view.hpp
10 10 // Models a Unary Function 11 11 template <typename P> // Models PixelValueConcept 12 12 struct mandelbrot_fn { 13 typedef point2< ptrdiff_t> point_t;13 typedef point2<std::ptrdiff_t> point_t; 14 14 15 15 typedef mandelbrot_fn const_t; 16 16 typedef P value_type; … … 27 27 mandelbrot_fn() {} 28 28 mandelbrot_fn(const point_t& sz, const value_type& in_color, const value_type& out_color) : _in_color(in_color), _out_color(out_color), _img_size(sz) {} 29 29 30 ptrdiff_t width() { return _img_size.x; }31 ptrdiff_t height() { return _img_size.y; }30 std::ptrdiff_t width() { return _img_size.x; } 31 std::ptrdiff_t height() { return _img_size.y; } 32 32 33 33 result_type operator()(const point_t& p) const { 34 34 // normalize the coords to (-2..1, -1.5..1.5) -
libs/gil/io/test/png_old_test.cpp
17 17 18 18 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 19 19 { 20 point2< ptrdiff_t > dim = png_read_dimensions( png_filename );20 point2< std::ptrdiff_t > dim = png_read_dimensions( png_filename ); 21 21 22 22 BOOST_CHECK_EQUAL( dim.x, 1000 ); 23 23 BOOST_CHECK_EQUAL( dim.y, 600 ); -
libs/gil/io/test/pnm_old_test.cpp
17 17 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 18 18 { 19 19 { 20 point2< ptrdiff_t > dim = pnm_read_dimensions( pnm_filename );20 point2< std::ptrdiff_t > dim = pnm_read_dimensions( pnm_filename ); 21 21 22 22 BOOST_CHECK_EQUAL( dim.x, 256 ); 23 23 BOOST_CHECK_EQUAL( dim.y, 256 ); -
libs/gil/io/test/targa_old_test.cpp
17 17 18 18 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 19 19 { 20 point2< ptrdiff_t > dim = targa_read_dimensions( targa_filename );20 point2< std::ptrdiff_t > dim = targa_read_dimensions( targa_filename ); 21 21 22 22 BOOST_CHECK_EQUAL( dim.x, 124 ); 23 23 BOOST_CHECK_EQUAL( dim.y, 124 ); -
libs/gil/io/test/tiff_old_test.cpp
24 24 25 25 BOOST_AUTO_TEST_CASE( old_read_dimensions_test ) 26 26 { 27 point2< ptrdiff_t > dim = tiff_read_dimensions( tiff_filename );27 point2< std::ptrdiff_t > dim = tiff_read_dimensions( tiff_filename ); 28 28 29 29 BOOST_CHECK_EQUAL( dim.x, 1000 ); 30 30 BOOST_CHECK_EQUAL( dim.y, 600 ); -
libs/gil/test/image.cpp
1 1 /* 2 2 Copyright 2005-2007 Adobe Systems Incorporated 3 3 4 4 Use, modification and distribution are subject to the Boost Software License, 5 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 6 http://www.boost.org/LICENSE_1_0.txt). 7 7 8 8 See http://opensource.adobe.com/gil for most recent version including documentation. 9 9 */ 10 // image_test.cpp : 10 // image_test.cpp : 11 11 // 12 12 13 13 #ifdef _MSC_VER … … 34 34 extern rgb8c_planar_view_t sample_view; 35 35 void error_if(bool condition); 36 36 37 38 37 // When BOOST_GIL_GENERATE_REFERENCE_DATA is defined, the reference data is generated and saved. 39 38 // When it is undefined, regression tests are checked against it 40 39 //#define BOOST_GIL_GENERATE_REFERENCE_DATA … … 71 70 72 71 struct my_color_converter { 73 72 template <typename SrcP,typename DstP> 74 void operator()(const SrcP& src,DstP& dst) const { 73 void operator()(const SrcP& src,DstP& dst) const { 75 74 typedef typename color_space_type<SrcP>::type src_cs_t; 76 75 typedef typename color_space_type<DstP>::type dst_cs_t; 77 76 my_color_converter_impl<src_cs_t,dst_cs_t>()(src,dst); … … 144 143 template <typename View> 145 144 struct view_is_homogeneous : public pixel_is_homogeneous<typename View::value_type> {}; 146 145 147 148 146 //////////////////////////////////////////////////// 149 147 /// 150 148 /// Tests image view transformations and algorithms … … 177 175 template <typename Img> void image_all_test(const string& prefix); 178 176 }; 179 177 180 181 178 // testing image iterators, clone, fill, locators, color convert 182 179 template <typename Img> 183 180 void image_test::basic_test(const string& prefix) { … … 246 243 check_view(hist_view,prefix+"histogram"); 247 244 } 248 245 249 250 246 template <typename View> 251 247 void image_test::view_transformations_test(const View& img_view, const string& prefix) { 252 248 check_view(img_view,prefix+"original"); … … 260 256 check_view(rotated90ccw_view(img_view),prefix+"90ccw"); 261 257 check_view(flipped_up_down_view(img_view),prefix+"flipped_ud"); 262 258 check_view(flipped_left_right_view(img_view),prefix+"flipped_lr"); 263 check_view(subsampled_view(img_view,typename View::point_t(2,1)),prefix+"subsampled"); 259 check_view(subsampled_view(img_view,typename View::point_t(2,1)),prefix+"subsampled"); 264 260 check_view(kth_channel_view<0>(img_view),prefix+"0th_k_channel"); 265 261 homogeneous_view_transformations_test(img_view, prefix, view_is_homogeneous<View>()); 266 262 } … … 270 266 check_view(nth_channel_view(img_view,0),prefix+"0th_n_channel"); 271 267 } 272 268 273 274 269 void image_test::virtual_view_test() { 275 270 typedef mandelbrot_fn<rgb8_pixel_t> deref_t; 276 271 typedef deref_t::point_t point_t; … … 320 315 check_view(view(any_img), "dynamic_"); 321 316 check_view(flipped_left_right_view(view(any_img)), "dynamic_fliplr"); 322 317 check_view(flipped_up_down_view(view(any_img)), "dynamic_flipud"); 323 318 324 319 any_image_t::view_t subimageView=subimage_view(view(any_img),0,0,10,15); 325 320 326 321 check_view(subimageView, "dynamic_subimage"); … … 353 348 image_all_test<bgr121_image_t>("bgr121_"); 354 349 355 350 // TODO: Remove? 356 view_transformations_test(subsampled_view(sample_view,point2< ptrdiff_t>(1,2)),"subsampled_");351 view_transformations_test(subsampled_view(sample_view,point2<std::ptrdiff_t>(1,2)),"subsampled_"); 357 352 view_transformations_test(color_converted_view<gray8_pixel_t>(sample_view),"color_converted_"); 358 353 359 354 virtual_view_test(); … … 363 358 finalize(); 364 359 } 365 360 366 367 368 361 //////////////////////////////////////////////////// 369 362 /// 370 363 /// Performs or generates image tests using checksums … … 394 387 395 388 // Load the checksums from the reference file and create the start image 396 389 void checksum_image_test::initialize() { 397 string crc_name; 390 string crc_name; 398 391 boost::crc_32_type::value_type crc_result; 399 392 fstream checksum_ref(_filename,ios::in); 400 393 while (true) { … … 449 442 checksum_ref.close(); 450 443 } 451 444 452 453 445 //////////////////////////////////////////////////// 454 446 /// 455 447 /// Performs or generates image tests using image I/O … … 499 491 }; 500 492 #endif 501 493 502 503 504 505 506 507 508 509 494 void static_checks() { 510 495 gil_function_requires<ImageConcept<rgb8_image_t> >(); 511 496 … … 559 544 typedef image_test_t image_mgr_t; 560 545 #endif 561 546 562 563 547 void test_image(const char* ref_checksum) { 564 548 image_mgr_t mgr(ref_checksum); 565 549 … … 568 552 } 569 553 570 554 int main(int argc, char* argv[]) { 571 572 555 const char* local_name = "gil_reference_checksums.txt"; 573 556 const char* name_from_status = "../libs/gil/test/gil_reference_checksums.txt"; 574 557 … … 586 569 } 587 570 588 571 return 0; 589 } 590 572 } 573 No newline at end of file -
libs/gil/test/pixel_iterator.cpp
1 1 /* 2 2 Copyright 2005-2007 Adobe Systems Incorporated 3 3 4 4 Use, modification and distribution are subject to the Boost Software License, 5 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 6 http://www.boost.org/LICENSE_1_0.txt). … … 55 55 boost::function_requires<HasDynamicXStepTypeConcept<bgr121_ptr_t> >(); 56 56 57 57 // TEST dynamic_step_t 58 BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_step_ptr_t,dynamic_x_step_type<cmyk16_step_ptr_t>::type>::value )); 59 BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_planar_step_ptr_t,dynamic_x_step_type<cmyk16_planar_ptr_t>::type>::value )); 58 BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_step_ptr_t,dynamic_x_step_type<cmyk16_step_ptr_t>::type>::value )); 59 BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_planar_step_ptr_t,dynamic_x_step_type<cmyk16_planar_ptr_t>::type>::value )); 60 60 61 61 BOOST_STATIC_ASSERT(( boost::is_same<iterator_type<bits8,gray_layout_t,false,false,false>::type,gray8c_ptr_t>::value )); 62 62 … … 76 76 typedef dynamic_x_step_type<rgb2gray_ptr>::type rgb2gray_step_ptr; 77 77 BOOST_STATIC_ASSERT(( boost::is_same< rgb2gray_step_ptr, dereference_iterator_adaptor<rgb8_step_ptr_t, ccv_rgb_g_fn> >::value)); 78 78 79 80 79 make_step_iterator(rgb2gray_ptr(),2); 81 80 82 81 typedef dereference_iterator_adaptor<rgb8_step_ptr_t, ccv_rgb_g_fn> rgb2gray_step_ptr1; … … 97 96 typedef bit_aligned_pixel_iterator<bgr232_ref_t> bgr232_ptr_t; 98 97 99 98 // BGR232 pixel value. It is a packed_pixel of size 1 byte. (The last bit is unused) 100 typedef std::iterator_traits<bgr232_ptr_t>::value_type bgr232_pixel_t; 99 typedef std::iterator_traits<bgr232_ptr_t>::value_type bgr232_pixel_t; 101 100 BOOST_STATIC_ASSERT((sizeof(bgr232_pixel_t)==1)); 102 101 103 102 bgr232_pixel_t red(0,0,3); // = 0RRGGGBB, = 01100000 104 103 105 104 // a buffer of 7 bytes fits exactly 8 BGR232 pixels. 106 unsigned char pix_buffer[7]; 105 unsigned char pix_buffer[7]; 107 106 std::fill(pix_buffer,pix_buffer+7,0); 108 107 bgr232_ptr_t pix_it(&pix_buffer[0],0); // start at bit 0 of the first pixel 109 108 for (int i=0; i<8; ++i) { … … 127 126 buf[2] = 219; 128 127 129 128 iterator_t it( &buf[0], 0 ); 130 129 131 130 ref_t p1 = *it; it++; 132 131 ref_t p2 = *it; it++; 133 132 ref_t p3 = *it; it++; … … 168 167 template <typename T> inline void ignore_unused_variable_warning(const T&){} 169 168 170 169 void test_pixel_iterator() { 171 172 170 rgb8_pixel_t rgb8(1,2,3); 173 171 rgba8_pixel_t rgba8; 174 172 … … 200 198 stepIt++; 201 199 rgb8_step_ptr_t stepIt2=stepIt+10; 202 200 stepIt2=stepIt; 203 201 204 202 rgb8_step_ptr_t stepIt3(&rgb8,5); 205 203 206 204 rgb8_pixel_t& ref1=stepIt3[5]; … … 214 212 ++rgb8StepIt; 215 213 rgb8_ref_t reff=*rgb8StepIt; ignore_unused_variable_warning(reff); 216 214 rgb8StepIt+=10; 217 ptrdiff_t dst=rgb8StepIt2-rgb8StepIt; ignore_unused_variable_warning(dst);215 std::ptrdiff_t dst=rgb8StepIt2-rgb8StepIt; ignore_unused_variable_warning(dst); 218 216 219 220 217 rgb8_pixel_t val1=ref1; 221 218 rgb8_ptr_t ptr=&ref1; 222 219 … … 255 252 // *pix_img_it_c=rgb8_pixel_t(1,2,3); // error: assigning though const iterator 256 253 typedef iterator_from_2d<rgb8_loc_t>::difference_type dif_t; 257 254 dif_t dt=0; 258 ptrdiff_t tdt=dt; ignore_unused_variable_warning(tdt);255 std::ptrdiff_t tdt=dt; ignore_unused_variable_warning(tdt); 259 256 260 261 262 257 // memory_based_step_iterator<rgb8_pixel_t> stepIt3Err=stepIt+10; // error: non-const from const iterator 263 258 264 259 memory_based_2d_locator<rgb8_step_ptr_t> xy_locator(ptr,27); … … 279 274 rgb8c_planar_ptr_t cp(&rgb8); 280 275 rgb8_planar_ptr_t p(&rgb8); 281 276 // get_color(p,red_t()) = get_color(cp,green_t()); // does not compile - cannot assign a non-const pointer to a const pointer. Otherwise you will be able to modify the value through it. 282 283 277 } 284 278 // xy_locator.y()++; 285 279 … … 287 281 // 288 282 // values, references, pointers 289 283 // color spaces (rgb,cmyk,gray) 290 // channel ordering (bgr vs rgb) 291 // planar vs interleaved 284 // channel ordering (bgr vs rgb) 285 // planar vs interleaved 292 286 293 287 // Pixel POINTERS 294 288 // typedef const iterator_traits<rgb8_ptr_t>::pointer RGB8ConstPtr; … … 300 294 RGB8ConstPtr rgb8_const_ptr=NULL; ignore_unused_variable_warning(rgb8_const_ptr); 301 295 rgb8_ptr_t rgb8ptr=&rgb8; 302 296 303 304 297 rgb8=bgr8_pixel_t(30,20,10); 305 298 rgb8_planar_ptr_t rgb8_pptr=&rgb8; 306 299 ++rgb8_pptr; … … 313 306 314 307 rgb8_pptr=&rgb8; 315 308 316 317 309 // rgb8_const_planar_ptr=&rgb16p; // error: incompatible bit depth 318 310 319 311 // iterator_traits<CMYK8>::pointer cmyk8_ptr_t=&rgb8; // error: incompatible pointer type … … 324 316 rgb8_ref_t rgb8ref_2=*rgb8ptr; ignore_unused_variable_warning(rgb8ref_2); 325 317 assert(rgb8ref_2==rgb8); 326 318 // RGB8Ref rgb8ref_2_err=*rgb8_const_planar_ptr; // error: non-const reference from const pointer 327 319 328 320 rgb8_planar_ref_t rgb8planarref_3=*rgb8_pptr; // planar reference from planar pointer 329 321 assert(rgb8planarref_3==rgb8); 330 322 // RGB8Ref rgb8ref_3=*rgb8_planar_ptr_t; // error: non-planar reference from planar pointer 331 323 332 333 324 const rgb8_pixel_t crgb8=rgb8; 334 325 *rgb8_pptr=rgb8; 335 326 *rgb8_pptr=crgb8; … … 342 333 int main(int argc, char* argv[]) { 343 334 test_pixel_iterator(); 344 335 return 0; 345 } 346 336 } 337 No newline at end of file