boost

Boost not statically linking in to boost::python shared object

荒凉一梦 提交于 2020-01-13 05:27:26
问题 I've created a wrapper for my application using boost::python. This has worked so far by: (number of static libraries/source code) -> python_mapping.so In this way my shared object is comprised of many static libs, including boost itself (notably boost_thread). I would assume that this so would contain ALL my application information, as I've statically linked everything in. This compiles just fine. ldd python_mapping.so librt.so.1 => /lib64/librt.so.1 (0x00002b7cbad37000) libstdc++.so.6 =>

How do I loop over a boost MPL list of non-default constructed classes?

荒凉一梦 提交于 2020-01-13 03:55:11
问题 I have the following example: #include <iostream> #include <boost/mpl/for_each.hpp> #include <boost/mpl/list.hpp> struct one {}; struct two {}; struct three {}; struct four {}; struct five { five() = delete; }; template <typename T> void print() { std::cout << "hello " << typeid(T).name() << std::endl; } struct type_printer { template <typename T> void operator()(T) { print<T>(); } }; int main() { typedef boost::mpl::list< one, two, three, four, five >::type type_list; boost::mpl::for_each

Boost asio send and receive messages

百般思念 提交于 2020-01-13 03:44:08
问题 I'm trying to send and receive messages from a client and server using TCP. I'm trying it with threading, and I don't know how to do this at all. I can connect to the server just fine, but I need to be able to send and receive messages from both places on demand. I've been searching for hours and have come up empty, as all of the results on Google are overcomplicated and cluttering. struct Client { boost::asio::ip::tcp::socket socket; Client(const char* host = HOST, const char* port = PORT) :

Starvation with upgrade_lock

被刻印的时光 ゝ 提交于 2020-01-13 03:22:26
问题 I am trying to use Boost's upgrade_lock (using this example, but I run into a starvation issue. I am actually using the code from this post, but I wanted an up-to-date discussion. I run 400 threads after the WorkerKiller . I run into the exact same problem as anoneironaut , the author of the mentionned post. I have seen the proposition from Howard Hinnant , but I don't really want to include more external code (moreover I cannot get his to compile as of now) and a comment posted 6 months

Starvation with upgrade_lock

倾然丶 夕夏残阳落幕 提交于 2020-01-13 03:22:06
问题 I am trying to use Boost's upgrade_lock (using this example, but I run into a starvation issue. I am actually using the code from this post, but I wanted an up-to-date discussion. I run 400 threads after the WorkerKiller . I run into the exact same problem as anoneironaut , the author of the mentionned post. I have seen the proposition from Howard Hinnant , but I don't really want to include more external code (moreover I cannot get his to compile as of now) and a comment posted 6 months

Boost filesystem incredibly slow?

拥有回忆 提交于 2020-01-12 13:46:30
问题 I am currently in the process of learning the Boost framework, and I have found out how to list all folders and files on my system, using #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <iostream> using namespace std; int main() { for ( boost::filesystem::recursive_directory_iterator end, dir("C:\\"); dir != end; ++dir ) { cout << *dir << std::endl; } return 0; } but the only problem I'm having is how slow the process is... am I doing something wrong or is it just that

Boost shared_from_this and destructor

眉间皱痕 提交于 2020-01-12 10:08:46
问题 I found that it is not allowed to call shared_from_this in the destructor from a class: https://svn.boost.org/trac/boost/ticket/147 This behavior is by design. Since the destructor will destroy the object, it is not safe to create a shared_ptr to it as it will become dangling once the destructor ends. I understand the argument, but what if I need a "shared_from_this" pointer for cleaning up references ( not for sharing owner ship). Here is an example where I'm not using shared_ptr: class A{

boost::asio internal threads

人走茶凉 提交于 2020-01-12 09:16:03
问题 When using boost::asio for some asynchronous TCP communication I noticed it starts a lot of (3-4) internal threads. Reading in the documentation, it says "The implementation of this library for a particular platform may make use of one or more internal threads to emulate asynchronicity" Now my lib has very strict requirements to not start any extra threads (except one that is supplied by the client and which now starts io_service::run() ). Is there any way to stop boost::asio from creating

boost::asio internal threads

强颜欢笑 提交于 2020-01-12 09:14:04
问题 When using boost::asio for some asynchronous TCP communication I noticed it starts a lot of (3-4) internal threads. Reading in the documentation, it says "The implementation of this library for a particular platform may make use of one or more internal threads to emulate asynchronicity" Now my lib has very strict requirements to not start any extra threads (except one that is supplied by the client and which now starts io_service::run() ). Is there any way to stop boost::asio from creating

Get 32-bit hash value from boost::hash

人走茶凉 提交于 2020-01-12 07:41:11
问题 I am using boost::hash to get hash value for a string. But it is giving different hash values for same string on Windows 32-bit and Debian 64-bit systems. So how can I get same hash value (32-bit or 64-bit) using boost::hash irrespective of platform? 回答1: What is the guarantee concerning boost::hash ? I don't see any guarantees that a generated hash code is usable outside of the process which generates it. (This is frequently the case with hash functions.) If you need a hash value for