Category : boost

The code below prints worldworld to the console rather than hello world. I can fix this by changing sig.connect([&]() { slot(); }); to sig.connect(slot), but don’t understand why. What’s happening? #include <iostream> #include <boost/signals2.hpp> void add_slot(boost::signals2::signal<void()> &sig, std::function<void()> slot) { sig.connect([&]() { slot(); }); } int main() { boost::signals2::signal<void()> sig; add_slot(sig, []() { std::cout << ..

Read more

New here to boost, I am trying to get the deadline_timer to work with async_wait (it works with wait(). However, i cannot seem to be able to pass the required handler as an argument. This is pseudo of my current code: namespace net = boost::asio; class LDserver { private: std::shared_ptr<net::io_service> io_service = std::make_shared<net::io_service>(); net::deadline_timer timer ..

Read more

I have this CMakeLists.txt set(Boost_USE_STATIC_LIBS ON) find_package(Boost REQUIRED COMPONENTS json) include_directories(${BOOST_INCLUDE_DIRS}) target_link_libraries(<Target> PRIVATE Boost::json) But I get cmake warnings [cmake] CMake Warning at C:/Program Files/CMake/share/cmake3.20/Modules/FindBoost.cmake:2185 (message): [cmake] No header defined for json; skipping header check (note: header-only [cmake] libraries have no designated component) The project can configure and build tho. But the compile_command.json I found ..

Read more

I have a simple program where I’d like to use <boost/multiprecision/mpfr.hpp>. ex.xpp: #include <iostream> #include <boost/multiprecision/mpfr.hpp> int main() { std::cout << "Hello, World!" << std::endl; return 0; } However, when I try to compile I get the following error: … % g++ ex.cpp In file included from ex.cpp:2: In file included from /usr/local/include/boost/multiprecision/mpfr.hpp:9: In file ..

Read more