Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2007-05-19 18:40:38


>
> I am glad to know I still the have skill of breaking compilers. :)
>
Well, I seem to have similar skills. The code below crashes my
compiler ( VC7.1 SP 1), as well.

void print( const std::string& s )
{
   std::cout << s;
}

int main ( int, char** )
{
   typedef boost::shared_ptr<A> A_ptr_t;
   typedef boost::shared_ptr<D> D_ptr_t;

   typedef std::vector < boost::shared_ptr<Base> > Data_t;
   Data_t m_data;

   A_ptr_t a ( new A ( 50 ) );
   D_ptr_t d ( new D ( 30 ) );

   m_data.push_back ( a );
   m_data.push_back ( d );

   boost::uint32_t indent_value = 4;

   // this works
   boost::bind( &print
              , boost::bind( &Base::to_String
                           , A_ptr_t( new A( 5 ) )
                           , indent_value ))();

   // this doesn't work - ICE
   std::for_each ( m_data.begin(),
                   m_data.end(),
                   boost::bind( &print
                              , boost::bind( &Base::to_String
                                           , boost::bind::_1
                                           , indent_value )));

   return 0;
}

I know this is not the solution. I'm still using a seperate function
print() for outputting. I will keep trying to solve that one.

On the other hand it would be nice if boost::bind comes some handy
function like the print(). Just a thought.

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