473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

boost.bind problems

Hi,

at this time I try to combine Qt and boost. Unfortunately I've run into
trouble:

void QWidget::insertAction ( QAction * before, QAction * action );
class QAction : public QWidget { ... };

class ActionCategory {
...
QList<QAction*m_actionList;
};

....
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, _2));

which shall replace:

foreach(QAction* action, m_actionList)
insertAction(0, action);
What's wrong?

Thanks
Olaf

The error is:
Gui/ActionCategory.cpp: In member function »QMenu*
eda::ActionCategory::updateMenu(QMenu*)«:
Gui/ActionCategory.cpp:240: Fehler: expected `)' before numeric constant
/usr/include/boost/bind.hpp: At global scope:
/usr/include/boost/bind.hpp: In instantiation of
»boost::_bi::result_traits<boost::_bi::unspecified , void
(QWidget::*)(QAction*, QAction*)>«:
/usr/include/boost/bind/bind_template.hpp:15: instantiated from
»boost::_bi::bind_t<boost::_bi::unspecified, void (QWidget::*)(QAction*,
QAction*), boost::_bi::list2<boost::arg<1>, boost::arg<2 >«
Gui/ActionCategory.cpp:240: instantiated from here
/usr/include/boost/bind.hpp:64: Fehler: »void (QWidget::*)(QAction*,
QAction*)« ist kein Klassen-, Struktur- oder Union-Typ
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:
In function »_Function std::for_each(_InputIterator, _InputIterator,
_Function) [with _InputIterator = QList<QAction*>::iterator, _Function =
boost::_bi::bind_t<boost::_bi::unspecified, void (QWidget::*)(QAction*,
QAction*), boost::_bi::list2<boost::arg<1>, boost::arg<2 >]«:
Gui/ActionCategory.cpp:240: instantiated from here
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:159:
Fehler: keine Übereinstimmung für Aufruf von
»(boost::_bi::bind_t<boost::_bi::unspecified, void
(QWidget::*)(QAction*, QAction*), boost::_bi::list2<boost::arg<1>,
boost::arg<2 >) (QAction*&)«
Feb 21 '07 #1
1 3818
On 21 Feb, 19:55, Olaf Petzold <o...@mdcc.dewrote:
Hi,

at this time I try to combine Qt and boost. Unfortunately I've run into
trouble:

void QWidget::insertAction ( QAction * before, QAction * action );
class QAction : public QWidget { ... };

class ActionCategory {
...
QList<QAction*m_actionList;

};

...
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, _2));
for_each takes a unary function.
boost::bind(&QWidget::insertAction, _1, 0, _2)
creates a binary function and for_each will only
bind _1, _2 is left unbound
which shall replace:

foreach(QAction* action, m_actionList)
insertAction(0, action);
I suppose you want something like
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, action) );
instead
Feb 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: P G | last post by:
I hope this is on topic here. I have a problem compiling a simple example of the use of boost::bind. Please take a look at the program below. ...
16
by: Jeff Flinn | last post by:
At the risk of raising the OT ire of some here, I'd like to know what might be done to raise the awareness of the boost libraries. I've found boost and it's libraries invaluable in my work for ~5...
13
by: Russell Hind | last post by:
I'm trying to use boost::bind and boost::function inside managed code, but there appears to be some code generation problems. The following code compiles fine, but the function object throws an...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
6
by: Toby Bradshaw | last post by:
Hi, Consider the following: class A { public: virtual bool foo() = 0; };
6
by: Alex Buell | last post by:
I think one of the program snippets in the Boost's Bind library is wrong. I've just been trying to find the error in this program as below, perhaps there's an typo in there somewhere but I can't...
1
by: Tigera | last post by:
Greetings, I am trying to learn to use the Boost library, and I've run into a frustrating problem with the line marked here: #include <boost/function.hpp> #include <boost/functional.hpp>...
3
by: =?iso-8859-1?B?Tm9yZGz2dw==?= | last post by:
Hey there, C++ Coders! I am learning multi-threading with boost and have come up with the following code example shown below. This example implements a test of the producer-consumer design...
3
by: Giovanni Gherdovich | last post by:
Hello, in the following code I have a pointer (to function), say p, of type double (*)(double, double, void*) and I try to fix the second argument of the function *p to a given value (using...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.