boost

How to use Boost Spirit auto rules with AST?

醉酒当歌 提交于 2021-01-27 07:53:08
问题 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_

Resetting sleeping time of a thread

自作多情 提交于 2021-01-27 07:42:42
问题 Suppose to have a thread like this void mythread() { int res; while(1) { { boost::lock_guard<boost::mutex> lock(mylock); res = do_my_stuff(); } boost::this_thread::sleep(boost::posix_time::seconds(5)); } } and that the thread is currently sleeping. If something happens outside of the thread, I'd like to be able to increase the sleep time. What is the best way to do it? 回答1: Using a condition_variable to signal changes to the deadline This has the benefit of supporting scenarios where the

Using BOOST_STRONG_TYPEDEF to differentiate arg types but causing seg fault

你离开我真会死。 提交于 2021-01-27 07:24:50
问题 I have a method requiring several variables of the same enum type. To allow the compiler to detect if I pass the wrong argument I am using BOOST_STRONG_TYPEDEF . However, I get a seg fault when I create an instance and compare within an IF statement. Boost version is 1.74 enum class Testable { UNDEFINED, A, B }; BOOST_STRONG_TYPEDEF(Testable, SomeType) int main() { SomeType abc{Testable::UNDEFINED}; std::cout << "START" << std::endl; if(abc == Testable::UNDEFINED) // Seg faults here {

C++: Can't propagate polymorphic_allocator with scoped_allocator_adaptor

荒凉一梦 提交于 2021-01-27 05:24:39
问题 I have a vector<vector<int>> and want the entire memory (i.e., of both the outer and the inner vector) to be taken from a memory_resource . Here is a stripped down example, first the boring part: #include <boost/container/pmr/memory_resource.hpp> #include <boost/container/scoped_allocator.hpp> #include <boost/container/pmr/polymorphic_allocator.hpp> #include <iostream> #include <string> #include <vector> // Sample memory resource that prints debug information class MemoryResource : public

Wrap C++ template class with boost python

被刻印的时光 ゝ 提交于 2021-01-27 04:11:29
问题 I am try to wrap a C++ template class with booth python. I get errors with the current wrapper. The program is basically for creating customized vector's and use it in python. #include <boost/python.hpp> template <class T> class allocator{ public: T* allocate(size_t); void deallocate(T* , size_t); void construct(T*,T); void destroy(T*); }; template <class T> class vec{ typedef T* iterator; typedef const T* const_iterator; typedef size_t size_type; typedef T value_type; vec(){ create(); }

What if the system time changes while I'm doing timed_wait with a duration?

别等时光非礼了梦想. 提交于 2021-01-27 03:54:19
问题 When using timed_wait on a boost::condition_variable with a duration, will the wait condition time out after the duration even if the user (or ntp) changes the system time? E.g., boost::posix_time::time_duration wait_duration(0, 0, 1, 0); // 1 sec // ** System time jumps back 15 minutes here. ** if( !signal.timed_wait(lock, wait_duration) ) { // Does this condition happen 1 second later, or about 15 minutes later? } 回答1: As of the date of writing (Nov 2013), if the wall-clock time changes

What if the system time changes while I'm doing timed_wait with a duration?

北城余情 提交于 2021-01-27 03:53:24
问题 When using timed_wait on a boost::condition_variable with a duration, will the wait condition time out after the duration even if the user (or ntp) changes the system time? E.g., boost::posix_time::time_duration wait_duration(0, 0, 1, 0); // 1 sec // ** System time jumps back 15 minutes here. ** if( !signal.timed_wait(lock, wait_duration) ) { // Does this condition happen 1 second later, or about 15 minutes later? } 回答1: As of the date of writing (Nov 2013), if the wall-clock time changes

What if the system time changes while I'm doing timed_wait with a duration?

强颜欢笑 提交于 2021-01-27 03:52:38
问题 When using timed_wait on a boost::condition_variable with a duration, will the wait condition time out after the duration even if the user (or ntp) changes the system time? E.g., boost::posix_time::time_duration wait_duration(0, 0, 1, 0); // 1 sec // ** System time jumps back 15 minutes here. ** if( !signal.timed_wait(lock, wait_duration) ) { // Does this condition happen 1 second later, or about 15 minutes later? } 回答1: As of the date of writing (Nov 2013), if the wall-clock time changes

Which compilers support std::filesystem?

岁酱吖の 提交于 2021-01-27 02:55:06
问题 Thanks to C++11, after a long relationship with boost, the last component that makes me depend on it is the filesystem. std::filesystem seems to be implemented as experimental according to the link: Filesystem library Since it mimics boost::filesystem, I can easily adapt my project into std and get rid of huge boost dependency. Which compilers support it and would it matter to use it even though it is experimental since it mimics boost (since there is no time schedule for when it will be

What is a jamfile?

时光总嘲笑我的痴心妄想 提交于 2021-01-27 01:41:56
问题 I'm trying to use the boost_1_55_0 libraries and I keep coming across references to jamfiles. What are jamfiles? Why are there things like bjam and multiple versions of jamfiles? 回答1: Jam is an open source make system built by Perforce. Bjam is a boost variant of jam. One of the advantages of jam is that it is explicitly designed to be a platform independent build system, in contrast to other build systems such as make. 来源: https://stackoverflow.com/questions/22901555/what-is-a-jamfile