boost

WriteHandler from boost::asio::async_write doesn't work properly when connection is dropped (firewall / manual disconecting the network)

穿精又带淫゛_ 提交于 2021-02-05 08:14:09
问题 I've been trying to write a client-server application using boost::asio, overall the application works great but I've stumbled over a problem regarding the data provided by 'WriteHandler' ( async_write function) when the connoction (between client <> server) is droped by a firewalll or by manualy disabling a newtwork card. Here is the code snippet: void write(const CommunicatorMessage & msg, std::function<void(bool)> writeCallback) { io_service.dispatch( [this, msg, writeCallback]() { boost:

circular_buffer and managed_mapped_file segmentation fault

一世执手 提交于 2021-02-05 08:08:42
问题 I am using boost 1.73.0, and am trying to use circular_buffer together with manage_mapped_file to store strings in a circular buffer persisted on disk. I do the following to create/open the circular_buffer: boost::interprocess::managed_mapped_file mmf(boost::interprocess::open_or_create, "./circ_buffer.bin", 10u << 10); typedef boost::interprocess::allocator<std::string, boost::interprocess::managed_mapped_file::segment_manager> string_allocator; typedef boost::circular_buffer<std::string,

Boost Python - Global and Local dictionary

僤鯓⒐⒋嵵緔 提交于 2021-02-05 07:49:07
问题 I'm using BoostPython for embedding Python in my C++ project but I don't understand all stuffs about Python, especially the namespace system. Actually, I used this code: byte_code = Py_CompileString(filedata, filename, Py_file_input); // [...] PyObject* res = NULL; PyObject* main_module = PyImport_AddModule("__main__"); PyObject* global_dict = PyModule_GetDict(main_module); PyObject* local_dict = PyDict_New(); py::object local_namespace(py::handle<>(py::borrowed(local_dict))); // Set a user

compile boost under linux without being root [closed]

耗尽温柔 提交于 2021-02-05 07:49:06
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question how i can compile boost under linux without write in system folders. I need to get headers files and shared libraries of boost in one my specific folder. 回答1: You don't need to be root to compile Boost on Linux. Moreover, many Boost libraries are header only so no

Boost Spirit lexeme vs no_skip

本小妞迷上赌 提交于 2021-02-05 07:46:36
问题 As like the description on Boost.Spirit, the only difference between lexeme and no_skip is the pre_skip. But after some test, I'm still confusing about the exactly meaning for pre_skip. So what kind of condition will make a difference, maybe a example can help me understand it much better. Thanks! 回答1: Pre-skip ignores whitespace at the start of the expression. Contrasting: Live On Coliru #include <boost/spirit/include/qi.hpp> namespace qi = boost::spirit::qi; static std::string const input =

boost::variant with bool and string

好久不见. 提交于 2021-02-05 07:11:34
问题 I'm having trouble with boost::variant (using boost 1.67.0). When my template parameter list includes both bool and std::string , any variant objects which should be treated as string, seem to be implicitly bound to bool instead. For example: using Varval = boost::variant<bool, std::string>; void main() { std::vector<Varval> vect{ true, false, "Hello_World" }; std::cout << "[ "; for (const auto &v : vect) std::cout << v << " "; std::cout << "]\n"; } Outputs: [ 1 0 1 ] whereas if I change

Iterating on xml file with boost

风格不统一 提交于 2021-02-05 06:55:27
问题 I am new with boost and xml and I am trying to scan an xml file and save some specific values. I read this article and my question is: if the xml contains several <sked> , how do I iterate both of them? maybe BOOST_FOREACH () BOOST_FOREACH () // nested loop lets say the given xml file as follow (the purpose is to save both IDs): <?xml version="1.0"? encoding="utf-8"?> <arrayOfSked> <sked> <ID> 1 </ID> <version>2</version> <flight> <carrier>BA</carrier> <number>4001</number> <precision>0.1<

Is the epoch of steady_clock relative to when the operating system starts? or to the process itself?

99封情书 提交于 2021-02-05 06:01:41
问题 Using boost::chrono::steady_clock or std::chrono::steady_clock is suppose to guarantee that physical time is always monotonic and is not affected by date time changes in the system. Here is my question, if I have two processes that need to be immune to system date time changes, is it enough to exchange just the time_since_epoch ? In other words, the time interpretation of the two processes to the same time since epoch will be the same? Specifically I need to answer this question for Windows

ptree get_value with name including “.”

自闭症网瘾萝莉.ら 提交于 2021-02-04 21:18:13
问题 "A": "1" "A.B": "2" "A.C": "3" How to get the value of A.B if i iterate through the ptree it works. if i try to get value of pt.get_child("A\.B").get_value<std::string>() . i get the following exception terminate called after throwing an instance of boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_path> >' what(): No such node please find the complete code below #include <boost/property_tree/ptree.hpp> #include <boost/property

ptree get_value with name including “.”

半世苍凉 提交于 2021-02-04 21:18:07
问题 "A": "1" "A.B": "2" "A.C": "3" How to get the value of A.B if i iterate through the ptree it works. if i try to get value of pt.get_child("A\.B").get_value<std::string>() . i get the following exception terminate called after throwing an instance of boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_path> >' what(): No such node please find the complete code below #include <boost/property_tree/ptree.hpp> #include <boost/property