The code below does not compile in Visual C++ 2005.
class SomeClass {
public: boost::function<void()> func;
SomeClass(boost::function<void()> &func): func(func) { }
};
void someFunc() {
std::cout << "someFunc" << std::endl;
}
int main() {
SomeClass sc(boost::function<void()>(&someFunc));
sc.func(); // error C2228: ...
Hello all:
First a disclaimer, I am replacing a bunch of code which uses boost::function and boost::bind. However, I am moving to a codebase which does not allow rtti. I would like to keep using boost but don't know if there is a way around this restriction.
So..., I am trying to mimic some of its functionality, but much more simplif...
Hi,
I have this function signature I have to match
typedef int (*lua_CFunction) (lua_State *L);//target sig
Here's what I have so far:
//somewhere else...
...
registerFunction<LuaEngine>("testFunc", &LuaEngine::testFunc, this);
...
//0 arg callback
void funcCallback0(boost::function<void ()> func, lua_State *state)...
I am going to try to ask this question without supplying too much source code because all the relevant bits add up to a bunch. The key (I think?) objects involved are
using namespace o2scl;
typedef MSMTModel<TASensor,PosModel,target2d,ovector,ovector_const_subvector> TA_MSMTModel;
typedef MPC_funct_mfptr<MSMT_InitialState,TA_MSMTModel...
I have a worker class like the one below:
class Worker{
public:
int Do(){
int ret = 100;
// do stuff
return ret;
}
}
It's intended to be executed with boost::thread and boost::bind, like:
Worker worker;
boost::function<int()> th_func = boost::bind(&Worker::Do, &worker);
boost::thread th(th_func);
th.join();
My quest...
I'm in the process of implementing a platform independent wrapper for dynamically loaded libraries. Of course when I load functions from the libraries I need to store them as pointers for future use. I thought of using boost::function's for that instead of normal function pointers. Sure, that will increase compile time, but that's not wh...
I have the following code that uses a for loop and I would like to use transform, or at least for_each instead, but I can't see how.
typedef std::list<boost::function<void(void) > CallbackList;
CallbackList callbacks_;
//...
for(OptionsMap::const_iterator itr = options.begin(); itr != options.end(); ++itr)
{
callbacks_.push_back(boo...
Hey all -
I'm working through setting up a member function as a callback for a C-library that I'm using. The C-library sets up callbacks like this:
typedef int (*functionPointer_t)(myType1_t*, myType2_t*, myType3_t*);
setCallback(param1, param2, functionPointer, param4)
I would like to use boost::bind (if possible) to pass in the fu...
Why is this boost::lambda expression not working?
boost::function<bool (boost::uint64_t, boost::uint64_t&, unsigned int, float)> myFunct = boost::lambda::_3 < 1;
I get theses compilation errors, that won't probably help, because they are really cryptic.
|| In file included from /usr/include/boost/function/detail/maybe_include.hpp:33,...
Hello,
I wanted to know how fast is a single-inheritance virtual function call when compared to one same boost::function call. Are they almost the same in performance or is boost::function slower?
I'm aware that performance may vary from case to case, but, as a general rule, which is faster, and to a how large degree is that so?
Thank...
I'm using boost::function to enable the passing of a function to a Button constructor so it holds that function. Calling it whenever it is activated.
typedef boost::function< void() > Action;
In my TitleState I've constructed a Button like this.
m_play(
ButtonAction, // This is where I pass a function to Button's Action argume...
The following code causes cl.exe to crash (MS VS2005).
I am trying to use boost bind to create a function to a calls a method of myclass:
#include "stdafx.h"
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <functional>
class myclass {
public:
void fun1() { printf("fun1()\n"); }
void fun2(int i) {...
Hi,
I'm trying to create predicate for std::find_if by using boost::bind together with boost::contains (from boost/algoritm/string library).
Following snippet shows two ways how I'm trying to accomplish this.
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <iostream>
#include <s...
I've got a function that I want to take an optional boost::function argument as a callback for reporting an error condition. Is there some special value I can use a the default value to make it optional?
For example, with a regular function pointer I can do:
void my_func(int a, int b, t_func_ptr err_callback=NULL) {
if (error && (...
This is for the purpose of a client/server program. The client asks for some data off the server, and receives it. Upon receiving this data from a Boost socket on the client side, I handle this message in a static method called parse_message in a class called client_protocol.
This method, given this specific data, will start a process o...
Some C++ objects have no copy constructor, but have move constructor.
For example, boost::promise.
How can I bind those objects using their move constructors ?
#include <boost/thread.hpp>
void fullfil_1(boost::promise<int>& prom, int x)
{
prom.set_value(x);
}
boost::function<void()> get_functor()
{
// boost::promise is not copyab...
Given the following member function overload to take various functors
class Foo {
public:
void bar(boost::function<void(int)> func);
void bar(boost::function<void(float)> func);
void bar(boost::function<void(const std::vector<float>&)> func);
}
and the function
void baz(float f) { std::cout << "float :" << f << st...
Since I love progamming in both C# and C++, I'm about to implementing a C#-like event system as a solid base for my planned C++ SFML-GUI.
This is only an excerpt of my code and I hope this clarifies my concept:
// Event.h
// STL headers:
#include <functional>
#include <type_traits>
#include <iostream>
// boost headers:
#include <boost/...
Hi,
I have a class which contains boost::function as one of its arguments. I have to make this class equality comparable but the boost::function is not equality comparable. Is there a easy workaround for this problem?
Thanks,
Gokul.
...
Hello, I have to pass function into pointer. For this purposes I'm using boost::function. The function which catches the pointer is overloaded for different signatures. For example:
void Foo(boost::function<int ()>) { ... }
void Foo(boost::function<float ()>) { ... }
void Foo(boost::function<double ()>) { ... }
Now I wanna pass some c...