boost

how to subtract one path from another?

不羁岁月 提交于 2020-01-14 10:43:00
问题 So... I have a base path and a new path.New path contains in it base path. I need to see what is different in new path. Like we had /home/ and new path is /home/apple/one and I need to get from it apple/one. note - when I would create some path from (homePath/diffPath) I need to get that /home/apple/one again. How to do such thing with Boost FileSystem? 回答1: Using stem() and parent_path() and walk backwards from the new path until we get back to base path, this works, but I am not sure if it

Can not link Boost Graph Library for read_graphviz() example

大兔子大兔子 提交于 2020-01-14 10:30:08
问题 I am trying to do an example with read_graphviz but I can not help the linker to link the read_graphviz function call to the correct version read_graphviz. At http://www.boost.org/doc/libs/1_61_0/libs/graph/doc/read_graphviz.html there are three template versions of read_graphviz: namespace boost { template <typename MutableGraph> bool read_graphviz(std::istream& in, MutableGraph& graph, dynamic_properties& dp, const std::string& node_id = "node_id"); template <typename MutableGraph> bool

does c++ have an equivalent boost::numeric_cast<DestType>(SourceType)?

一个人想着一个人 提交于 2020-01-14 10:22:00
问题 I am doing a bunch of applied-mathematics/signal-processing/algorithms C++ code. I have enabled the -Wconversion compiler warning to catch issues like runtime conversion of numbers that are type double to type int32_t . Obviously I am always concerned during these conversions because: loss of the numbers decimal value possible positive or negative overflow ("positive overflow" is when a double has a value greater than INT32_MAX and tries to store that value in the destination type ( int32_t

Boost Serializing of Object containing Map (with object values) and Multimap (with std::string values): what is needed?

孤街醉人 提交于 2020-01-14 08:01:17
问题 See below a main() and two very simple classes. Then per Boost serialization (and what is shown) my questions are: 1) Does class B need the normal overloaded stream insertion operators '<<' and '>>' to be defined? Currently in my real code it doesn't have these. 2) Does class A in the store() and load() methods need to iterate through the map and multimap containers explicitely, storing/loading their key:value pairs explicitely? e.g. something like: void A::store(const char* filename){ std:

How to change the default formatting with boost::log::BOOST_TRIVIAL_LOG?

痴心易碎 提交于 2020-01-14 07:27:07
问题 boost::log looks really powerful. It offers a BOOST_LOG_TRIVIAL macro for trivial logging. But how can I change the default formatting? It prints the timestamp by default, by I don't want it. Do you have any idea? It seems the only way is to define a new sink ex-novo and add it to the core, then you can call set_format() on the backend in case. But this is no "trivial" anymore. 回答1: Boost.Log has a default sink, which is used as long as you do not provide your own sink. The following code

Write CMakeLists.txt for boost::mpi

纵饮孤独 提交于 2020-01-14 06:31:10
问题 The cmake file below is the source of problem because I can compile the code with mpic++ directly and without using cmake. Why the cmake file below doesn't work? Current cmake file: cmake_minimum_required(VERSION 2.8) project(boost_mpi_cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_executable(test test.cpp) find_package(Boost REQUIRED mpi system) include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(test ${Boost_LIBRARIES}) find_package(MPI REQUIRED) include

Create solid polygon in boost geometry

风格不统一 提交于 2020-01-13 20:34:14
问题 I'm newbie at boost geometry, I have created polygon with boost::geometry::assign_points() . But I only create outer and inner of that polygon is empty. So I try test boost::geometry::overlaps() with two polygons A, B and A is inside B, result is not overlaps. So, What can I do to create solid polygon (only know outer point of polygon and inside of polygon is valid) ? 回答1: Polygons are by definition solid until you subtract inner rings. From §6.1.11.1 from the standard¹: A Polygon is a planar

Using C++ and Boost (or not?) to check if a specific port is being used?

早过忘川 提交于 2020-01-13 19:57:49
问题 I am trying to check if a specific port is being used in C++. I am not trying to have the C++ program listen on that port for any reason, just check to see if it is being used. There will be another program listening on that port, and if it stops, I want my program to do something. So, it will check every 10 seconds or so, and if the port is in use, it will do nothing, but if the port becomes available, something will happen. I've been looking at the boost ASIO library, but I can't seem to

Using C++ and Boost (or not?) to check if a specific port is being used?

為{幸葍}努か 提交于 2020-01-13 19:57:34
问题 I am trying to check if a specific port is being used in C++. I am not trying to have the C++ program listen on that port for any reason, just check to see if it is being used. There will be another program listening on that port, and if it stops, I want my program to do something. So, it will check every 10 seconds or so, and if the port is in use, it will do nothing, but if the port becomes available, something will happen. I've been looking at the boost ASIO library, but I can't seem to

What is the performance difference between strand.post and strand.wrap?

丶灬走出姿态 提交于 2020-01-13 19:50:23
问题 What is the performance difference between strand::post() and strand::wrap() ? And what's the story about race condition when use strand::wrap( )? 回答1: Just for clarification, strand::wrap only creates a handler, neither the provided handler nor returned handler are dispatched or posted to the io_service . If the result from strand::wrap is executed, then performance differences from overhead is negligible. However, a perceived performance difference could occur as the result of the wrapped