boost

How do you print to console in a Multi-Threaded MEX Function?

巧了我就是萌 提交于 2021-01-28 00:19:17
问题 I'm writing a simple producer consumer MEX function which uses the Boost library. I have manged to get the following program to work without any issues. #include "mex.h" #include <boost/thread/thread.hpp> #include <boost/lockfree/spsc_queue.hpp> #include <iostream> #include <boost/atomic.hpp> int producer_count = 0; boost::atomic_int consumer_count (0); boost::lockfree::spsc_queue<int, boost::lockfree::capacity<1024> > spsc_queue; const int iterations = 10000000; void producer() { for (int i

unable to construct runtime boost spsc_queue with runtime size parameter in shared memory

主宰稳场 提交于 2021-01-27 22:18:28
问题 I want to make a lock free ring buffer in shared memory using runtime specified maximum number of entries. I am basing my code off an example I found in GitHub. I successfully created a lock free ring buffer in shared memory using this code. In my case, I need to specify the maximum number of entries that the ring buffer can accept at runtime construction and not at compile time per the example. The call to construct the shm::ring_buffer in the example is shown below. namespace bip = boost:

boost::filesystem::path(std::wstring) throw exception

最后都变了- 提交于 2021-01-27 20:34:31
问题 this code: boost::filesystem::is_directory("/usr/include"); work fine. both this code: boost::filesystem::is_directory(L"/usr/include"); throw an exception: terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid OS - Linux Mint boost-1.43 gcc-4.6.0 回答1: Don't use wide strings on Linux. You don't need them.. What happens that it tries to convert wide string to normal one and for this creates a locale and probably this locale

Storing or accessing objects in boost r-tree

岁酱吖の 提交于 2021-01-27 19:37:21
问题 I am using Boost's r-tree implementation in my code. I have a list of objects with coordinates (say cities on a map, if it matters), which I wish to index in the r-tree, to perform fast NN search, etc. I have followed their iterative query example, in which trees are storing boost::geometry::model::point objects. My question: is there anyway to store objects ( i.e. the cities themselves) instead of just their coordinates in the tree? One solution I thought about is to use indexing of my own.

\mingw-w64\ … \ld.exe: cannot find -lboost_filesystem

感情迁移 提交于 2021-01-27 17:32:23
问题 I'm trying to compile simple c++ program with mingw on "windows 7 64bit" command prompt. Error I get is: >gcc fs.cpp -lboost_filesystem -lboost_system c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_filesystem c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find

Derived class offset calculation in boost::serialization. Is it valid?

巧了我就是萌 提交于 2021-01-27 14:05:37
问题 boost::serialization contains this code: reinterpret_cast<std::ptrdiff_t>( static_cast<Derived *>( reinterpret_cast<Base *>(1 << 20) ) ) - (1 << 20) Its purpose is to calculate an offset between base and derived classes. Is this code free of undefined behaviour? The reason why I am asking is that ASAN+UBSAN complain. For example, this code #include <iostream> class Foo { public: virtual void foo() {} }; class Base { public: virtual void base() {} }; class Derived: public Foo, public Base {};

Send and receiving compressed files with boost over socket

血红的双手。 提交于 2021-01-27 13:05:09
问题 In my project, read and write messages over socket are compressed with Zlib Filters of boost, i would like to know how to do the same with files . what better way for better speed? Save the data in buffer without use hard disk? I'm having trouble to transferring files using boost, so any help and examples are welcome. I am using the following code to send compressed messages: std::string data_ std::stringstream compressed; std::stringstream original; original << data_; boost::iostreams:

How to use boost::multiprecision::float128 in with Xcode

痴心易碎 提交于 2021-01-27 12:11:25
问题 I am trying to use boost::multiprecision::float128 in xCode project. My compiler version is Apple clang version 11.0.0 (clang-1100.0.20.17) Target: x86_64-apple-darwin18.7.0 Thread model: posix I am using boost.1.71.0 I am getting following compile error 'quadmath.h' file not found in float128.hpp extern "C" { #include <quadmath.h> } I saw several threads regarding to this issue https://svn.boost.org/trac10/ticket/8265 19 months ago by John Maddock (clang has no support for float128 and

How to use Boost Spirit auto rules with AST?

别说谁变了你拦得住时间么 提交于 2021-01-27 07:57:32
问题 EDIT: I expanded sehe's example to show the problem when I want to use it on another rule: http://liveworkspace.org/code/22lxL7$17 I'm trying to improve the performances of my Boost Spirit parser and I saw that since C++11, it was possible to use auto-rules like that: auto comment = "/*" >> *(char_ - "*/") >> "*/"; (or with BOOST_AUTO or BOOST_SPIRIT_AUTO). I have a rule declarer like that: qi::rule<lexer::Iterator, ast::SimpleType()> simple_type; and defined like that: simple_type %= const_

How to use Boost Spirit auto rules with AST?

我们两清 提交于 2021-01-27 07:53:17
问题 EDIT: I expanded sehe's example to show the problem when I want to use it on another rule: http://liveworkspace.org/code/22lxL7$17 I'm trying to improve the performances of my Boost Spirit parser and I saw that since C++11, it was possible to use auto-rules like that: auto comment = "/*" >> *(char_ - "*/") >> "*/"; (or with BOOST_AUTO or BOOST_SPIRIT_AUTO). I have a rule declarer like that: qi::rule<lexer::Iterator, ast::SimpleType()> simple_type; and defined like that: simple_type %= const_