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 Mateusz Loskot, 10 years ago)

Adds missing std:: qualifier to ptrdiff_t in GIL tests and examples

  • libs/gil/example/interleaved_ptr.hpp

     
    11/*
    22    Copyright 2005-2007 Adobe Systems Incorporated
    3    
     3
    44    Use, modification and distribution are subject to the Boost Software License,
    55    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    66    http://www.boost.org/LICENSE_1_0.txt).
     
    1111/*************************************************************************************************/
    1212
    1313////////////////////////////////////////////////////////////////////////////////////////
    14 /// \file               
     14/// \file
    1515/// \brief Example on how to create a pixel iterator
    1616/// \author Lubomir Bourdev and Hailin Jin \n
    1717///         Adobe Systems Incorporated
     
    2828#include "interleaved_ref.hpp"
    2929
    3030namespace boost { namespace gil {
    31 
    3231/////////////////////////////////////////////////////////////////////////
    3332///
    3433/// A model of an interleaved pixel iterator. Contains an iterator to the first channel of the current pixel
    3534///
    36 /// Models: 
     35/// Models:
    3736///     MutablePixelIteratorConcept
    3837///        PixelIteratorConcept
    3938///           boost_concepts::RandomAccessTraversalConcept
     
    8281    // Channels accessor (not required by any concept)
    8382    const ChannelPtr& channels()            const { return _channels; }
    8483          ChannelPtr& channels()                  { return _channels; }
    85    
     84
    8685    // Not required by concepts but useful
    8786    static const std::size_t num_channels = mpl::size<typename Layout::color_space_t>::value;
    8887private:
     
    9291
    9392    void increment()            { _channels+=num_channels; }
    9493    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; }
    9695
    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; }
    9897    bool equal(const interleaved_ptr& it) const { return _channels==it._channels; }
    9998
    10099    reference dereference() const { return reference(_channels); }
     
    110109// GIL's planar reference and iterator ("planar_pixel_reference" and "planar_pixel_iterator") which share the class "pixel" as the value_type. The
    111110// class "pixel" is also the value type for interleaved pixel references. Here we are dealing with channels, not pixels, but the principles still apply.
    112111template <typename ChannelPtr, typename Layout>
    113 struct const_iterator_type<interleaved_ptr<ChannelPtr,Layout> > { 
     112struct const_iterator_type<interleaved_ptr<ChannelPtr,Layout> > {
    114113private:
    115114    typedef typename std::iterator_traits<ChannelPtr>::reference channel_ref_t;
    116115    typedef typename channel_traits<channel_ref_t>::const_pointer channel_const_ptr_t;
    117116public:
    118     typedef interleaved_ptr<channel_const_ptr_t,Layout> type; 
     117    typedef interleaved_ptr<channel_const_ptr_t,Layout> type;
    119118};
    120119
    121120template <typename ChannelPtr, typename Layout>
     
    157156/////////////////////////////
    158157
    159158template <typename ChannelPtr, typename Layout>
    160 inline std::ptrdiff_t memunit_step(const interleaved_ptr<ChannelPtr,Layout>&) { 
     159inline std::ptrdiff_t memunit_step(const interleaved_ptr<ChannelPtr,Layout>&) {
    161160    return sizeof(typename std::iterator_traits<ChannelPtr>::value_type)*   // size of each channel in bytes
    162161           interleaved_ptr<ChannelPtr,Layout>::num_channels;                // times the number of channels
    163162}
    164163
    165164template <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()); 
     165inline 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());
    168167}
    169168
    170169template <typename ChannelPtr, typename Layout>
    171 inline void memunit_advance(interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) { 
     170inline void memunit_advance(interleaved_ptr<ChannelPtr,Layout>& p, std::ptrdiff_t diff) {
    172171    memunit_advance(p.channels(), diff);
    173172}
    174173
     
    194193struct dynamic_x_step_type<interleaved_ptr<ChannelPtr,Layout> > {
    195194    typedef memory_based_step_iterator<interleaved_ptr<ChannelPtr,Layout> > type;
    196195};
    197 
    198196} }  // namespace boost::gil
    199197
    200 #endif
     198#endif
     199 No newline at end of file
  • libs/gil/example/mandelbrot.cpp

     
    11/*
    22    Copyright 2005-2007 Adobe Systems Incorporated
    3    
     3
    44    Use, modification and distribution are subject to the Boost Software License,
    55    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    66    http://www.boost.org/LICENSE_1_0.txt).
     
    2424// Models a Unary Function
    2525template <typename P>   // Models PixelValueConcept
    2626struct mandelbrot_fn {
    27     typedef point2<ptrdiff_t>    point_t;
     27    typedef point2<std::ptrdiff_t>    point_t;
    2828
    2929    typedef mandelbrot_fn        const_t;
    3030    typedef P                    value_type;
     
    7979    jpeg_write_view("out-mandelbrot.jpg",mandel);
    8080
    8181    return 0;
    82 }
    83 
     82}
     83 No newline at end of file
  • libs/gil/io/test/bmp_old_test.cpp

     
    1717
    1818BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    1919{
    20     point2< ptrdiff_t > dim = bmp_read_dimensions( bmp_filename );
     20    point2< std::ptrdiff_t > dim = bmp_read_dimensions( bmp_filename );
    2121
    2222    BOOST_CHECK_EQUAL( dim.x, 1000 );
    2323    BOOST_CHECK_EQUAL( dim.y, 600  );
  • libs/gil/io/test/jpeg_old_test.cpp

     
    1717
    1818BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    1919{
    20     point2< ptrdiff_t > dim = jpeg_read_dimensions( jpeg_filename );
     20    point2< std::ptrdiff_t > dim = jpeg_read_dimensions( jpeg_filename );
    2121
    2222    BOOST_CHECK_EQUAL( dim.x, 1000 );
    2323    BOOST_CHECK_EQUAL( dim.y,  600 );
  • libs/gil/io/test/mandel_view.hpp

     
    1010// Models a Unary Function
    1111template <typename P>   // Models PixelValueConcept
    1212struct mandelbrot_fn {
    13     typedef point2<ptrdiff_t>    point_t;
     13    typedef point2<std::ptrdiff_t>    point_t;
    1414
    1515    typedef mandelbrot_fn        const_t;
    1616    typedef P                    value_type;
     
    2727    mandelbrot_fn() {}
    2828    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) {}
    2929
    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; }
    3232
    3333    result_type operator()(const point_t& p) const {
    3434        // normalize the coords to (-2..1, -1.5..1.5)
  • libs/gil/io/test/png_old_test.cpp

     
    1717
    1818BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    1919{
    20     point2< ptrdiff_t > dim = png_read_dimensions( png_filename );
     20    point2< std::ptrdiff_t > dim = png_read_dimensions( png_filename );
    2121
    2222    BOOST_CHECK_EQUAL( dim.x, 1000 );
    2323    BOOST_CHECK_EQUAL( dim.y,  600 );
  • libs/gil/io/test/pnm_old_test.cpp

     
    1717BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    1818{
    1919    {
    20         point2< ptrdiff_t > dim = pnm_read_dimensions( pnm_filename );
     20        point2< std::ptrdiff_t > dim = pnm_read_dimensions( pnm_filename );
    2121
    2222        BOOST_CHECK_EQUAL( dim.x, 256 );
    2323        BOOST_CHECK_EQUAL( dim.y, 256 );
  • libs/gil/io/test/targa_old_test.cpp

     
    1717
    1818BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    1919{
    20     point2< ptrdiff_t > dim = targa_read_dimensions( targa_filename );
     20    point2< std::ptrdiff_t > dim = targa_read_dimensions( targa_filename );
    2121
    2222    BOOST_CHECK_EQUAL( dim.x, 124 );
    2323    BOOST_CHECK_EQUAL( dim.y, 124 );
  • libs/gil/io/test/tiff_old_test.cpp

     
    2424
    2525BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
    2626{
    27     point2< ptrdiff_t > dim = tiff_read_dimensions( tiff_filename );
     27    point2< std::ptrdiff_t > dim = tiff_read_dimensions( tiff_filename );
    2828
    2929    BOOST_CHECK_EQUAL( dim.x, 1000 );
    3030    BOOST_CHECK_EQUAL( dim.y,  600 );
  • libs/gil/test/image.cpp

     
    11/*
    22    Copyright 2005-2007 Adobe Systems Incorporated
    3    
     3
    44    Use, modification and distribution are subject to the Boost Software License,
    55    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    66    http://www.boost.org/LICENSE_1_0.txt).
    77
    88    See http://opensource.adobe.com/gil for most recent version including documentation.
    99*/
    10 // image_test.cpp : 
     10// image_test.cpp :
    1111//
    1212
    1313#ifdef _MSC_VER
     
    3434extern rgb8c_planar_view_t sample_view;
    3535void error_if(bool condition);
    3636
    37 
    3837// When BOOST_GIL_GENERATE_REFERENCE_DATA is defined, the reference data is generated and saved.
    3938// When it is undefined, regression tests are checked against it
    4039//#define BOOST_GIL_GENERATE_REFERENCE_DATA
     
    7170
    7271struct my_color_converter {
    7372    template <typename SrcP,typename DstP>
    74     void operator()(const SrcP& src,DstP& dst) const { 
     73    void operator()(const SrcP& src,DstP& dst) const {
    7574        typedef typename color_space_type<SrcP>::type src_cs_t;
    7675        typedef typename color_space_type<DstP>::type dst_cs_t;
    7776        my_color_converter_impl<src_cs_t,dst_cs_t>()(src,dst);
     
    144143template <typename View>
    145144struct view_is_homogeneous : public pixel_is_homogeneous<typename View::value_type> {};
    146145
    147 
    148146////////////////////////////////////////////////////
    149147///
    150148///  Tests image view transformations and algorithms
     
    177175    template <typename Img> void image_all_test(const string& prefix);
    178176};
    179177
    180 
    181178// testing image iterators, clone, fill, locators, color convert
    182179template <typename Img>
    183180void image_test::basic_test(const string& prefix) {
     
    246243    check_view(hist_view,prefix+"histogram");
    247244}
    248245
    249 
    250246template <typename View>
    251247void image_test::view_transformations_test(const View& img_view, const string& prefix) {
    252248    check_view(img_view,prefix+"original");
     
    260256    check_view(rotated90ccw_view(img_view),prefix+"90ccw");
    261257    check_view(flipped_up_down_view(img_view),prefix+"flipped_ud");
    262258    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");
    264260    check_view(kth_channel_view<0>(img_view),prefix+"0th_k_channel");
    265261    homogeneous_view_transformations_test(img_view, prefix, view_is_homogeneous<View>());
    266262}
     
    270266    check_view(nth_channel_view(img_view,0),prefix+"0th_n_channel");
    271267}
    272268
    273 
    274269void image_test::virtual_view_test() {
    275270    typedef mandelbrot_fn<rgb8_pixel_t> deref_t;
    276271    typedef deref_t::point_t            point_t;
     
    320315    check_view(view(any_img), "dynamic_");
    321316    check_view(flipped_left_right_view(view(any_img)), "dynamic_fliplr");
    322317    check_view(flipped_up_down_view(view(any_img)), "dynamic_flipud");
    323    
     318
    324319    any_image_t::view_t subimageView=subimage_view(view(any_img),0,0,10,15);
    325320
    326321    check_view(subimageView, "dynamic_subimage");
     
    353348    image_all_test<bgr121_image_t>("bgr121_");
    354349
    355350    // 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_");
    357352    view_transformations_test(color_converted_view<gray8_pixel_t>(sample_view),"color_converted_");
    358353
    359354    virtual_view_test();
     
    363358    finalize();
    364359}
    365360
    366 
    367 
    368361////////////////////////////////////////////////////
    369362///
    370363///  Performs or generates image tests using checksums
     
    394387
    395388// Load the checksums from the reference file and create the start image
    396389void checksum_image_test::initialize() {
    397     string crc_name; 
     390    string crc_name;
    398391    boost::crc_32_type::value_type crc_result;
    399392    fstream checksum_ref(_filename,ios::in);
    400393    while (true) {
     
    449442    checksum_ref.close();
    450443}
    451444
    452 
    453445////////////////////////////////////////////////////
    454446///
    455447///  Performs or generates image tests using image I/O
     
    499491};
    500492#endif
    501493
    502 
    503 
    504 
    505 
    506 
    507 
    508 
    509494void static_checks() {
    510495    gil_function_requires<ImageConcept<rgb8_image_t> >();
    511496
     
    559544typedef image_test_t            image_mgr_t;
    560545#endif
    561546
    562 
    563547void test_image(const char* ref_checksum) {
    564548    image_mgr_t mgr(ref_checksum);
    565549
     
    568552}
    569553
    570554int main(int argc, char* argv[]) {
    571 
    572555    const char* local_name = "gil_reference_checksums.txt";
    573556    const char* name_from_status = "../libs/gil/test/gil_reference_checksums.txt";
    574557
     
    586569    }
    587570
    588571    return 0;
    589 }
    590 
     572}
     573 No newline at end of file
  • libs/gil/test/pixel_iterator.cpp

     
    11/*
    22    Copyright 2005-2007 Adobe Systems Incorporated
    3    
     3
    44    Use, modification and distribution are subject to the Boost Software License,
    55    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    66    http://www.boost.org/LICENSE_1_0.txt).
     
    5555    boost::function_requires<HasDynamicXStepTypeConcept<bgr121_ptr_t> >();
    5656
    5757// 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 ));
    6060
    6161    BOOST_STATIC_ASSERT(( boost::is_same<iterator_type<bits8,gray_layout_t,false,false,false>::type,gray8c_ptr_t>::value ));
    6262
     
    7676    typedef dynamic_x_step_type<rgb2gray_ptr>::type rgb2gray_step_ptr;
    7777    BOOST_STATIC_ASSERT(( boost::is_same< rgb2gray_step_ptr, dereference_iterator_adaptor<rgb8_step_ptr_t, ccv_rgb_g_fn> >::value));
    7878
    79 
    8079    make_step_iterator(rgb2gray_ptr(),2);
    8180
    8281    typedef dereference_iterator_adaptor<rgb8_step_ptr_t, ccv_rgb_g_fn> rgb2gray_step_ptr1;
     
    9796    typedef bit_aligned_pixel_iterator<bgr232_ref_t> bgr232_ptr_t;
    9897
    9998    // 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;
    101100    BOOST_STATIC_ASSERT((sizeof(bgr232_pixel_t)==1));
    102101
    103102    bgr232_pixel_t red(0,0,3); // = 0RRGGGBB, = 01100000
    104103
    105104    // a buffer of 7 bytes fits exactly 8 BGR232 pixels.
    106     unsigned char pix_buffer[7];   
     105    unsigned char pix_buffer[7];
    107106    std::fill(pix_buffer,pix_buffer+7,0);
    108107    bgr232_ptr_t pix_it(&pix_buffer[0],0);  // start at bit 0 of the first pixel
    109108    for (int i=0; i<8; ++i) {
     
    127126    buf[2] = 219;
    128127
    129128    iterator_t it( &buf[0], 0 );
    130    
     129
    131130    ref_t p1 = *it; it++;
    132131    ref_t p2 = *it; it++;
    133132    ref_t p3 = *it; it++;
     
    168167template <typename T> inline void ignore_unused_variable_warning(const T&){}
    169168
    170169void test_pixel_iterator() {
    171 
    172170    rgb8_pixel_t rgb8(1,2,3);
    173171    rgba8_pixel_t rgba8;
    174172
     
    200198    stepIt++;
    201199    rgb8_step_ptr_t stepIt2=stepIt+10;
    202200    stepIt2=stepIt;
    203    
     201
    204202    rgb8_step_ptr_t stepIt3(&rgb8,5);
    205203
    206204    rgb8_pixel_t& ref1=stepIt3[5];
     
    214212    ++rgb8StepIt;
    215213    rgb8_ref_t reff=*rgb8StepIt; ignore_unused_variable_warning(reff);
    216214    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);
    218216
    219 
    220217    rgb8_pixel_t val1=ref1;
    221218    rgb8_ptr_t ptr=&ref1;
    222219
     
    255252    //  *pix_img_it_c=rgb8_pixel_t(1,2,3);        // error: assigning though const iterator
    256253    typedef iterator_from_2d<rgb8_loc_t>::difference_type dif_t;
    257254    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);
    259256
    260 
    261 
    262257    //  memory_based_step_iterator<rgb8_pixel_t> stepIt3Err=stepIt+10;       // error: non-const from const iterator
    263258
    264259    memory_based_2d_locator<rgb8_step_ptr_t> xy_locator(ptr,27);
     
    279274    rgb8c_planar_ptr_t cp(&rgb8);
    280275    rgb8_planar_ptr_t p(&rgb8);
    281276//    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 
    283277    }
    284278//  xy_locator.y()++;
    285279
     
    287281    //
    288282    // values, references, pointers
    289283    // 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
    292286
    293287// Pixel POINTERS
    294288//  typedef const iterator_traits<rgb8_ptr_t>::pointer  RGB8ConstPtr;
     
    300294    RGB8ConstPtr rgb8_const_ptr=NULL; ignore_unused_variable_warning(rgb8_const_ptr);
    301295    rgb8_ptr_t rgb8ptr=&rgb8;
    302296
    303 
    304297    rgb8=bgr8_pixel_t(30,20,10);
    305298    rgb8_planar_ptr_t rgb8_pptr=&rgb8;
    306299    ++rgb8_pptr;
     
    313306
    314307    rgb8_pptr=&rgb8;
    315308
    316 
    317309    //  rgb8_const_planar_ptr=&rgb16p;                  // error: incompatible bit depth
    318310
    319311    //  iterator_traits<CMYK8>::pointer cmyk8_ptr_t=&rgb8;    // error: incompatible pointer type
     
    324316    rgb8_ref_t rgb8ref_2=*rgb8ptr; ignore_unused_variable_warning(rgb8ref_2);
    325317    assert(rgb8ref_2==rgb8);
    326318    //  RGB8Ref rgb8ref_2_err=*rgb8_const_planar_ptr;   // error: non-const reference from const pointer
    327    
     319
    328320    rgb8_planar_ref_t rgb8planarref_3=*rgb8_pptr; // planar reference from planar pointer
    329321    assert(rgb8planarref_3==rgb8);
    330322    //  RGB8Ref rgb8ref_3=*rgb8_planar_ptr_t; // error: non-planar reference from planar pointer
    331323
    332 
    333324    const rgb8_pixel_t crgb8=rgb8;
    334325    *rgb8_pptr=rgb8;
    335326    *rgb8_pptr=crgb8;
     
    342333int main(int argc, char* argv[]) {
    343334    test_pixel_iterator();
    344335        return 0;
    345 }
    346 
     336}
     337 No newline at end of file