boost-signals2

Boost::signals2 - descruction of an object with the slot

女生的网名这么多〃 提交于 2019-12-31 03:37:26
问题 Consider this: #include <boost/signals2.hpp> #include <iostream> struct object_with_slot { void operator()() { std::cout << "Slot called!" << std::endl; member = 50500; } int member; }; int main() { boost::signals2::signal<void ()> sig; object_with_slot * ptr = new object_with_slot; sig.connect(*ptr); delete ptr; sig(); } Output is "Slot called!" and no crash or anything. That's why I have a few questions: 1) Why there is no crash? 2) Why there is no crash even if the slot function assigns

boost::signals2 undefined-reference when linking libraries together

淺唱寂寞╮ 提交于 2019-12-24 00:38:27
问题 I would like to link two libraries to my program. The first one, defines an object (of class ProducerObject ) which emits a signal. The second library defines two classes: a slave class which contains several instances of ProducerObject and a master class which can subscribe to the signals of the ProducerObject throught the slave class. The code of the first lib is: ProducerObject.hpp: #ifndef PRODUCEROBJECT_HPP_ #define PRODUCEROBJECT_HPP_ #include <boost/shared_ptr.hpp> #include <boost

Visual Studio 2012 C++ compile error with Boost Signal2

我怕爱的太早我们不能终老 提交于 2019-12-12 10:33:14
问题 I am using Visual Studio 2012 Ultimate with the following Boost Signals2 code: at https://github.com/cfobel/boost_signals2/blob/master/hello_world_0.cpp It generates the following error: c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory(348): error C4996: 'std::_Uninitialized_copy0': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See

Upgrade to boost::signals2 in VS2013 results in C4996 warnings

纵饮孤独 提交于 2019-12-12 03:35:45
问题 From the following compiler warning message in VS2013: CL : warning : Boost.Signals is no longer being maintained and is now deprecated. Please switch to Boost.Signals2. To disable this warning message, define BOOST_SIGNALS_NO_DEPRECATION_WARNING . I upgraded my code from boost::signals to boost::signals2 . Now there are even more numerous ugly warnings that go on and on and on, where this is just the start of it: 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory(348):

How often to derive from boost::signals::trackable?

一世执手 提交于 2019-12-11 10:16:35
问题 When using Boost.Signals, boost allows you to derive from boost::signals::trackable in order to ease object/connection lifetime management (See the boost documentation). I am in an early stage of my project and I am thinking, whether to derive from boost::signals::trackable in every new class I write that might use Boost.Signals in the future or only in classes I am sure that they will need the functionality of the trackable bas e-class The main reason for th first approach would be to

What is wrong with this boost::lambda::bind usage?

天涯浪子 提交于 2019-12-11 00:55:24
问题 Is there something wrong in this code? I keep getting compilation errors. Basically I want to connect a void returning function to a signal which has a non void return type. Boost version: Release 1.46.1 #include <boost/signals2.hpp> #include <boost/lambda/bind.hpp> #include <boost/lambda/lambda.hpp> using namespace boost::signals2; void func() { printf("Func called!"); } main() { signal<int(int)> sig; sig.connect( (boost::lambda::bind(func), 1) ); } I get the following error while compiling:

Handle connection/disconnection of many signals/slots with boost::signals2

霸气de小男生 提交于 2019-12-09 03:38:37
问题 I've started using boost::signals2 instead of my old signals-code. I'm having a problem with administering multiple connections though. Here's my problem: I have many instances of the class Person: class Person { public: void SetName (string new_name) { name = new_name; NameChange (name); } string name; boost::signals2::signal<Person*> NameChange; }; I also have a people-browser, that must monitor a subset of all available people for changes. Since people can come and go from that subset I

Does the boost.signals2 library need to be built?

荒凉一梦 提交于 2019-12-09 01:24:27
问题 My system is having trouble building the boost libraries. I understand that most boost libraries are (fortunately) just headers that do not need to be build (with some exceptions). Does the boost :: signals2 library need to be built? Also is the boost.signals2 library dependant on the boost.signals library? 回答1: Signals is not header-only, signals2 is. But however, signals2 is explicitly developed for thread-safety and if you use boost.thread, this has to be compiled. As far as I know

wrapper for boost::signals2 with lifetime management for generic slots

假如想象 提交于 2019-12-08 11:50:12
问题 I would like to create a wrapper class for boost::signals2 for modules (threads) that emits signals to slots. I.e. a module should gain typical simple signalling capabilities (e.g. a public connect(...) method) by inheriting from my Signal class. I would also like to hide the actual signal-slot implementation that is used. A concrete slot inherits from a generic Slot base class which has a template parameter defining its signature. A slot is just a functor with the suitable signature. This

Why does enable_shared_from_this lack direct access to the embedded weak_ptr?

喜你入骨 提交于 2019-12-08 01:45:06
问题 I want to use boost signals2 with automatic connection management in a multithreaded application. My class inherits from enable_shared_from_this<> and i want to connect a member method from within another member method. The connection might be rebuilt frequently so my code should be as fast as possible (despite from the boost signals2 performance itself): typedef boost::signals2::signal<void ()> signal_type; struct Cat : public enable_shared_from_this<Cat> { void meow (); void connect (signal