boost

Generate string if boolean attribute is true (karma counterpart to qi::matches)

孤人 提交于 2020-01-13 18:55:24
问题 Imagine we want to parse and generate simple C++ member function declarations with Boost.Spirit. The Qi grammar might look like this: function_ %= type_ > id_ > "()" > matches["const"]; That means, whether the function is const is stored in a bool . How to write the corresponding generator with Karma? function_ %= type_ << ' ' << id_ << "()" << XXX[" const"]; Here, we want a directive that consumes a boolean attribute, executes the embedded generator if the attribute is true and does nothing

Generate string if boolean attribute is true (karma counterpart to qi::matches)

≯℡__Kan透↙ 提交于 2020-01-13 18:55:10
问题 Imagine we want to parse and generate simple C++ member function declarations with Boost.Spirit. The Qi grammar might look like this: function_ %= type_ > id_ > "()" > matches["const"]; That means, whether the function is const is stored in a bool . How to write the corresponding generator with Karma? function_ %= type_ << ' ' << id_ << "()" << XXX[" const"]; Here, we want a directive that consumes a boolean attribute, executes the embedded generator if the attribute is true and does nothing

How to use boost::python::iterator with return_internal_reference?

天大地大妈咪最大 提交于 2020-01-13 17:25:10
问题 I have a class Type which cannot be copied nor it contains default constructor. I have second class A that acts as a set of the above classes. This second class gives access via iterators and my iterator has dereference operator: class A { class iterator { [...] public: Type & operator*() { return instance; } private: Type instance; } [...] }; Now to expose that I wrote a boost::python code that looks like that: class_<A>("A", [...]) .def("__iter__", iterator<A, return_internal_reference<> >(

How can I search a container of objects for a data member value?

浪尽此生 提交于 2020-01-13 17:03:10
问题 I have an object type like this: struct T { int x; bool y; }; and a container of them like this: std::vector<T> v; and a burning desire to determine — in a single statement — whether any of the elements of v have y == true . This likely involves std::find_if . My understanding is that std::bind and boost::bind are for member functions and cannot be applied to member data. Because I dislike them, I wish to avoid: comparison functions/functors loops Because my environment is C++03, the

How can I install Dlib in a Heroku python web app using requirements.txt?

谁说胖子不能爱 提交于 2020-01-13 15:01:49
问题 I built a Python Flask web API that involves machine learning and I've had a lot of frustration deploying it on Heroku. The problem is, my app has a dependency on Dlib ( a library) and I can't seem to find a way to install in my Heroku server. I'm losing my mind trying to fix this and I can imagine other AI developers out there who might encounter this problem. Please help me Here is what I have done so far. I have tried not using a Buildpack by specifying dlib==19.4.0 along with its

Getting class and member type from pointer to member variable

天涯浪子 提交于 2020-01-13 14:54:10
问题 For example: template <typename T> void foo(T ptr) { typedef GET_CLASS_TYPE(T) ClassT; typedef GET_VALUE_TYPE(T) ValueT; // ... } struct Bar { int var; }; foo(&Bar::var); Inside the last function call to foo(...) , ClassT should be Bar and ValueT should be int . How can I do this with plain C++ (can't use C++11 features), or boost? 回答1: Not aware of any out-of-the-box Boost type trait to do this, but the same can be written by yourself using template specialization: template<typename T>

How to extract the Boost interprocess library

那年仲夏 提交于 2020-01-13 11:52:20
问题 I have a small project that is using only the boost::interprocess part from the Boost library. Is there an easy way of extracting all needed files only for that part of the library? 回答1: Use the Boost BCP utility. To extract interprocess only, you could use: $ mkdir /tmp/interprocess #bcp needs this $ bcp interprocess /tmp/interprocess This copies interprocess and dependencies to /tmp/interprocess . 来源: https://stackoverflow.com/questions/2150836/how-to-extract-the-boost-interprocess-library

C++ Process Management [closed]

半城伤御伤魂 提交于 2020-01-13 11:15:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Is there a well-known, portable, good library for C++ process management? I found a promising library called Boost.Process, but it's only a candidate for inclusion in the Boost library. Has anyone use this? Does anyone know why it isn't a part of Boost? 回答1: How much management do you need? Just fork/exec? IPC?

DFS in boost::graph with changing the graphs content

若如初见. 提交于 2020-01-13 10:39:07
问题 Minimal example: #include <boost/graph/graph_traits.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/depth_first_search.hpp> struct vertex { int number; }; struct edge {}; typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, vertex, edge> graph_t; typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; typedef boost::graph_traits<graph_t>::edge_descriptor edge_t; struct vertex_visitor : public boost::default_dfs_visitor { void discover

Boost.Thread wakes up too late in 1.58

让人想犯罪 __ 提交于 2020-01-13 09:55:36
问题 I have an application that needs to do work within certain windows (in this case, the windows are all 30 seconds apart). When the time is not within a window, the time until the middle of the next window is calculated, and the thread sleeps for that amount of time (in milliseconds, using boost::this_thread::sleep_for ). Using Boost 1.55, I was able to hit the windows within my tolerance (+/-100ms) with extreme reliability. Upon migration to Boost 1.58, I am never able to hit these windows.