Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2008-04-03 20:30:28


Hi John, I have asked Lubomir about a year back about that "feature".
He mentioned performance reasons, which I take is the right answer.

I'm sure you know about it. But for the sake of introducing gil to the
boost community, here is a little code.

#include <boost/gil/gil_all.hpp>

using namespace std;
using namespace boost;
using namespace gil;

struct min_init_channel {
   template <typename Channel>
   void operator()(Channel& c) const
   {
      c = channel_traits< Channel >::min_value();
   }
};

template < typename Pixel >
void min_init( Pixel& p )
{
   static_for_each( p, min_init_channel());
}

int main(int argc, char* argv[])
{
   rgb8_pixel_t p;
   min_init( p );

   assert( at_c<0>( p ) == 0 );
}

Question, can I use BOOST_FOR_EACH to get rid of the function object?

On the other hand there might be a case for having a boolean as a
parameter to the pixel constructor determining if the channels should
be initialized or not.

Greetings,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net