boost

Boost bimap fails to compile with gcc 10, c++20. Looking for temporary fix

跟風遠走 提交于 2021-01-19 05:44:33
问题 With gcc 10.1 and boost 1.73.0, the following code #include <boost/bimap.hpp> int main() { boost::bimap<int, int> lookup; } fails to compile with flags -O2 --std=c++20 , but will succeed with flags -O2 -std=c++17 (verified with compiler explorer). This is possibly related to the following issue: https://github.com/boostorg/bimap/pull/15 (deprecated std::allocator<void> ) Is there some workaround I can use for now to get this code to successfully compile with --std=c++20 ? 回答1: The reason

Can I use boost::copy_range on the result of boost::adaptors::transformed over std::array to get back another std::array?

半腔热情 提交于 2021-01-05 07:43:45
问题 This code works and generates the correct output ( 23 , as 2 and 3 are the sizes of the two std::vector<int> s in array_of_vectors : #include <array> #include <boost/range/adaptor/transformed.hpp> #include <iostream> #include <vector> using boost::adaptors::transformed; constexpr auto get_size = [](auto const& snip){ return snip.size(); }; int main() { std::array<std::vector<int>,2> array_of_vectors = { {std::vector<int>{1,1}, std::vector<int>{1,1,1}} }; auto array_of_sizes = array_of_vectors

c++ max_element every n element

百般思念 提交于 2021-01-04 06:00:48
问题 Is there a way to find the max element in a container comparing every N elements and return the index. Using STL, BOOST, or... another lib? with every N, I mean use the std::max_element, but change the increase in the for, from ++first, to first += n; // based on std::max_element #ifndef NEWTON_ALGORITHM_SEARCH_MAX_INDEX_HPP #define NEWTON_ALGORITHM_SEARCH_MAX_INDEX_HPP #include <iterator> #include <newton/functional.hpp> namespace newton { // SAME THAT STD::MAX_ELEMENT template<class

boost::geometry::union no result

*爱你&永不变心* 提交于 2021-01-03 06:26:58
问题 I'm trying to merge some polygons using boost::geometry::union_ but the output vector is empty for some entries. here is an example : #include <iostream> #include <vector> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/io/wkt/wkt.hpp> #include <boost/foreach.hpp> int main() { typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; polygon green,

recursive_directory_iterator throws exception

▼魔方 西西 提交于 2020-12-30 06:27:19
问题 I am using the boost iterator "recursive_directory_iterator" to recursively scan through a directory. However, when the iterator runs into a directory for which my application does not have access, exception of type "boost::filesystem3::filesystem_error" is thrown, which halts the iterator and the program aborts. Is there anyway I can instruct the iterator to skip over such directories. I tried the code suggested at Traversing a directory with boost::filesystem without throwing exceptions

Problem with Boost::Test

心不动则不痛 提交于 2020-12-29 07:25:27
问题 Why this (copied from boost site ) gives me an error?! in VS 2010 Ultimate: #include <boost\test\unit_test.hpp> #define BOOST_TEST_MODULE MyTest int add( int i, int j ) { return i+j; } BOOST_AUTO_TEST_CASE( my_test ) { // seven ways to detect and report the same error: BOOST_CHECK( add( 2,2 ) == 4 ); // #1 continues on error BOOST_REQUIRE( add( 2,2 ) == 4 ); // #2 throws on error if( add( 2,2 ) != 4 ) BOOST_ERROR( "Ouch..." ); // #3 continues on error if( add( 2,2 ) != 4 ) BOOST_FAIL( "Ouch..

Problem with Boost::Test

南笙酒味 提交于 2020-12-29 07:24:05
问题 Why this (copied from boost site ) gives me an error?! in VS 2010 Ultimate: #include <boost\test\unit_test.hpp> #define BOOST_TEST_MODULE MyTest int add( int i, int j ) { return i+j; } BOOST_AUTO_TEST_CASE( my_test ) { // seven ways to detect and report the same error: BOOST_CHECK( add( 2,2 ) == 4 ); // #1 continues on error BOOST_REQUIRE( add( 2,2 ) == 4 ); // #2 throws on error if( add( 2,2 ) != 4 ) BOOST_ERROR( "Ouch..." ); // #3 continues on error if( add( 2,2 ) != 4 ) BOOST_FAIL( "Ouch..

Cmake error: Could NOT find Boost (missing: Boost_INCLUDE_DIR)

纵然是瞬间 提交于 2020-12-26 07:12:39
问题 I am new to Cmake and Boost. I am now working on a program using cmake and need help. System: windows 7 Cmake version: 3.16.0-rc1 Boost version: boost_1_71_0. And boost is installed through .exe file. Gcc version: 4.8.1(rev5, Built by MinGW-W64 project) Visual studio: vs 2015 When I run cmake .. in build dir, no error occurs. The output is: The C compiler identification is MSVC 19.0.24215.1 The CXX compiler identification is MSVC 19.0.24215.1 Check for working C compiler: C:/Program Files

How to construct boost spsc_queue with runtime size parameter to exchange cv::Mat objects between two processes using shared memory?

醉酒当歌 提交于 2020-12-15 05:21:27
问题 Trying to implement a produced consumer scenario where one process feeds cv::Mat objects into a queue buffer. And the consumer consumes them. cv::Mat has a settable allocator that can be implemented for custom memory management, but I had no success in making it work. Popping from the que on consumer side led to segfaults. The closest I've got is this implementation whwre cv::Mat is serialized and deserialized. Another downside of this implementation is buffer size is defined during

How to make Boost dylibs universal (i386 & x86_64) on os x?

爱⌒轻易说出口 提交于 2020-12-09 04:17:08
问题 I'm trying to compile a Boost library into a universal binary file (i.e. a "fat" file that contains builds for both the i386 and x86_64 architectures). Souring the internet and SO I assembled the following instructions. Download boost (e.g. from http://www.boost.org/users/download/) In the downloaded folder, type ./bootstrap.sh (or, in my case ./bootstrap.sh --with-libraries=thread , since I only need the thread library) type ./b2 install cxxflags="-arch i386 -arch x86" These steps installed