Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ClassA & operator << ( ClassA &, int32_t )
- {
- ...
- }
- class ClassMain
- {
- public:
- insert( ClassA & c ) const;
- ...
- private:
- std::set<int> m_setContainer;
- };
- struct InsertOpt : binary_function<ClassA, int, ClassA&>
- {
- ClassA & operator( )( ClassA & c, int val ) const
- {
- c << val;
- return c;
- }
- };
- void ClassMain::insert( ClassA & c ) const
- {
- // Case I: the for loop works
- for ( std::set<int>::const_iterator iter = m_setContainer.begin( );
- iter != m_setContainer.end( ); ++iter )
- {
- c << *iter; // operator<<( c, *iter );
- }
- // Case II: doesn't work
- for_each( m_setContainer.begin( ), m_setContainer.end( ), bind1st( InsertOpt(), c ) );
- }
- Error:
- ../include/c++/4.1.2/bits/stl_function.h:406: error: no match for call to '(const InsertOpt) (const ClassA&, const int&)'
- note: candidates are: ClassA& InsertOpt::operator()(ClassA&, int32_t) const
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement