boost

Boost Spirit x3 conditional (ternary) operator parser (follow up question)

核能气质少年 提交于 2020-01-23 17:27:13
问题 This question is a follow up question for the one in Boost Spirit x3 conditional (ternary) operator parser The original question context did not show (my bad!) the ast attributes and the answer therefore could not take all the moving parts into account. This question now shows how the ast attributes looks like and how the ast is used to evaluate the expression with a symbol table. The follow up question is therefore that how the correctly spelled ternary conditional should change the ast

How can I install pyv8 in Ubuntu 14.04?

荒凉一梦 提交于 2020-01-23 13:49:50
问题 I installed the libv8 and libboost-all-dev Ubuntu packages, then ran sudo pip install pyv8 And got: building '_PyV8' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/src x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -Ilib/python/inc -Ilib/boost/inc -Ilib/v8/inc -I/usr/include/python2.7 -c src/Exception.cpp -o build/temp.linux-x86_64-2.7/src/Exception.o cc1plus: warning:

boost::asio::deadline_timer::async_wait not firing callback

独自空忆成欢 提交于 2020-01-23 12:07:28
问题 I have a boost io_service running in a thread, and I would like to fire a callback in that thread 6 seconds after a certain event happens to a client, and reset the timer for that client if it is already running. I maintain a unordered_map<string, shared_ptr<deadline_timer>> with a timer for each client. However, upon setting async_wait , my callback does not fire after the alloted amount of time (the io_service IS running), neither does it fire (with an error code) when I reset the pointer

Boost Asio - Server doesn't receive message

青春壹個敷衍的年華 提交于 2020-01-23 09:50:30
问题 I'm developing a 3d (first/third person) game and I'm trying to make it multiplayer using TCP sockets. I'm using the boost asio library for this, and I'm in a little over my head. I've played with the tutorials and examples a bit on the boost asio doc page and they compiled/ran/worked just fine, I'm just a little confused as to how everything works. Right now I'm just trying to make the server accept messages from the client, and print the message after receiving it. When I execute the code

Why boost::asio::async_read completion sometimes executed with bytes_transferred=0 and ec=0?

偶尔善良 提交于 2020-01-23 09:26:06
问题 Recently I have found an annoying problem with boost:asio::async_read . When I transfer large amounts of data, say a file of about 9GB, boost:asio::async_read works well in most of the time, but sometimes the completion of async_read is executed with bytes_transferred=0 and ec=0! And sometimes the completion of async_read is executed with bytes_transferred!=sp_recv_data->size() and ec still equal to 0. My code just like below: void CNetProactorClientImpl::async_recv() { auto sp_vec_buf = make

A way to filter range by indices, to get min_element from filtered indices only?

ぃ、小莉子 提交于 2020-01-23 06:12:18
问题 In comments to this question is-there-a-way-to-iterate-over-at-most-n-elements-using-range-based-for-loop there was additional question - is this possible to have "index view" on a container, i.e. to have subrange with some indexes filtered out. Additionally I encountered a problem to find minimum value from a range with some indexes filtered out. I.e. is it possible to replace such code as below with std and/or boost algorithms, filters - to make it more readable and maintainable: template

How to use boost::spirit to parse a sequence of words into a vector?

≡放荡痞女 提交于 2020-01-23 05:51:55
问题 I'm trying to learn boost::spirit . As an example, I'm trying to parse a sequence of words into a vector<string> . I tried this: #include <boost/spirit/include/qi.hpp> #include <boost/foreach.hpp> namespace qi = boost::spirit::qi; int main() { std::vector<std::string> words; std::string input = "this is a test"; bool result = qi::phrase_parse( input.begin(), input.end(), +(+qi::char_), qi::space, words); BOOST_FOREACH(std::string str, words) { std::cout << "'" << str << "'" << std::endl; } }

the counterpart of std::move in boost library

只愿长相守 提交于 2020-01-23 04:50:13
问题 I am trying to use std::move in my codes, but the compiler (g++ 4.4) I am using does not support it. Can boost::move substitute std::move completely? Thanks. 回答1: std::move (and boost::move when c++0x support is enabled) is just a cast from T& to T&& . It does not actually move anything. This means that the specific type of pointer T&& must be supported by the compiler. GCC supports r-value references since version 4.3, so the boost version should be fine. However, is there a reason you can't

How do you transfer ownership of an element of boost::ptr_vector?

一世执手 提交于 2020-01-22 19:38:22
问题 #include <boost/ptr_container/ptr_vector.hpp> #include <iostream> using namespace std; using namespace boost; struct A { ~A() { cout << "deleted " << (void*)this << endl; } }; int main() { ptr_vector<A> v; v.push_back(new A); A *temp = &v.front(); v.release(v.begin()); delete temp; return 0; } outputs: deleted 0x300300 deleted 0x300300 c(6832) malloc: *** error for object 0x300300: double free 回答1: ptr_vector<A>::release returns a ptr_vector<A>::auto_type , which is a kind of light-weight

Extract subset from boost dynamic_bitset

╄→гoц情女王★ 提交于 2020-01-22 18:51:13
问题 I need to extract and decode the bits (idx, idx+1, ... idx+n_bits) from a given boost dynamic_bitset. I have created the following solution: boost::dynamic_bitset<> mybitset(...); // build mask 2^{idx+n_bits} - 2^{idx} const boost::dynamic_bitset<> mask(mybitset.size(), (1 << idx+n_bits) - (1 << idx)); // shift the masked result idx times and get long unsigned long u = ((mybitset & mask) >> idx ).to_ulong(); It works well, but as this code is critical for the performance of my application, I