boost

BOOST_SPIRIT_DEFINE not understand

戏子无情 提交于 2021-02-10 18:20:42
问题 I'm trying to write an expression parser with boost spirit x3. I based my new code on old code that I written years ago (and worked well) with Spirit 2.x (qi). The core of my code is: //Make new rule(s) for expression auto term = factor >> *(('*' >> factor) | ('/' >> factor)); auto expression = term >> *(('+' >> term) | ('-' >> term)); auto group = '(' >> expression >> ')'; auto factor = lexeme["double_"] | group; string s="12.4 + 3.2"; auto first = s.begin(); auto last = s.end(); bool r = x3

Unknow file type: basic_oarchive.o (boost and emscripten)

天大地大妈咪最大 提交于 2021-02-10 16:55:00
问题 I'm trying to deserialize a file inside the browser (using boost.serialization). I compiled boost with emscripten apparently without issues. When compiling (linking in fact) my program, I get the error wasm-ld: error: unknown file type: basic_oarchive.o Here is the minimal source to reproduce the problem #include <iostream> #include <fstream> #include <boost/archive/binary_oarchive.hpp> #include <emscripten/bind.h> int main() { std::cout << "Run main" << std::endl; std::ofstream ofile("data

Boost::Process Pipe Streams and Unit Test

偶尔善良 提交于 2021-02-10 15:56:17
问题 I have source which two stream like this: bp::ipstream StdOut; bp::opstream StdIn; bp::child MyProcess = bp::child(processPath, bp::std_out > StdOut, bp::std_in < StdIn); // Doing some stuff with StdOut and StdIn I wanted to know if there is a way to write manually into this StdOut and read from StdIn in order to do unit tests? Thank you very much! 回答1: You can write to them as a normal stream: Live On Coliru #include <boost/process.hpp> #include <iostream> namespace bp = boost::process; int

How to use the boost io_service with a priority queue?

房东的猫 提交于 2021-02-10 15:41:58
问题 I have a program that have two function. one is a cycle timer, the other one is receiving some sockets. I found that, if there were more then one packages coming in before the timer tirggered, the boost will run all the socket-handles and then run the timer-handle. I wrote a simple code to simulate this timing like below: #include <iostream> #include <memory> #include <boost/asio.hpp> #include <boost/thread/thread.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/steady_timer.hpp

Is this the correct way of defining a set of recursive rules?

China☆狼群 提交于 2021-02-10 14:44:45
问题 PREFACE: I am asking this question because for some reason I can not get my code to compile. I just want to know whether an incorrect understanding of spirit::x3 is the cause or not Hello, I'd just like to verify something; is the following the correct way (at least technically) of defining rules for a large set of heavily recursive parsers? So for each parser, I do the following operations: // This is for reference only, it greatly simplifies the process of defining attributes. template

How to eliminate crashes when destroying boost::asio entities on fly?

主宰稳场 提交于 2021-02-10 09:22:33
问题 Note!!! The question is for people who are experts in boost::asio library . Unfortunately, I cannot do the code more compact, It contains a minimum amount to describe the problem. The code is example, artificially created. Places where it crashes known and described in comments, it is designed to illustrate the crashes!!! NO need any help with debugging of the code... The question is about how to design the asio server, not about - where it crashes!!! This example is close to "chat server"

Why does boost::interprocess::managed_shared_memory throw a boost::interprocess_exception upon construction?

ⅰ亾dé卋堺 提交于 2021-02-10 07:26:08
问题 In the code below, I'm trying to initialize a managed_shared_memory object. When the constructor is invoked I see the below error message - terminate called after throwing an instance of 'boost::interprocess::interprocess_exception' what(): boost::interprocess_exception::library_error Aborted why is this exception being thrown? I'm running this on an ubuntu 16.04 linux OS, compiled the program using g++ 9.3.0. Boost version 1.58.0 struct test_obj { size_t x; size_t y; uint8_t buf[32]; bool is

How to combine images with boost gil?

依然范特西╮ 提交于 2021-02-10 06:58:18
问题 I am just getting familiar with Boost GIL (and image processing in general) and suspect that this is simple, but I haven't found the relevant documentation. I have a set of image views that I would like to combine with an arbitrary function. For simplicity, lets say the images are aligned (same size and locator type) and I just want to add the pixel values together. One approach would be to create a combining iterator from a zip_iterator and a transform_iterator, but I'm guessing that there

Transform tuple to “triangular” tuple

和自甴很熟 提交于 2021-02-10 06:54:31
问题 How do I transform this type: std::tuple<T0, T1, ..., TN1, TN> into this: std::tuple< std::function<T0()>, std::function<T1(T0)>, std::function<T2(T0, T1)>, ... std::function<TN(T0, ..., TN1 )> > 回答1: Right ... isn't suffice, but you could always use pattern matching (i.e. partial specialization) with recursion: #include <tuple> #include <functional> #include <cstdlib> // A type to store list of integers template <size_t... ns> struct integers { template <size_t n> using push_back = integers

Boost::Spirit struggle with parsing a String

此生再无相见时 提交于 2021-02-10 06:14:37
问题 I'm trying to Parse a String with Boost::Spirit, but i just cannot get it to work. I have no experience with Boost::Spirit since today. The string is composed of commands separated by an ';'. The commands are "INC someInteger" "BOMB firstInteger secondInteger" "MOVE firstInteger secondInteger thirdInteger" "MSG someString" "WAIT" I Managed to get this far: #include <boost/spirit/include/qi.hpp> #include <boost/phoenix/phoenix.hpp> using namespace boost::spirit; int main() { std::string