boost

MinGW g++ doesn't find headers in its own include directory

十年热恋 提交于 2021-02-18 10:34:22
问题 So I recently installed MinGW via the latest version of nuwen's MinGW distribution that includes the boost C++ libraries. Specifically, I was after the scoped_ptr that the boost library provides. However, when I try to include the scoped_ptr ( #include <boost/scoped_ptr.hpp> ) in my header, the compiler throws error: boost/scoped_ptr.hpp: No such file or directory Makefile: compile: g++ -o gen/cavestory src/**.cc run: gen/cavestory Also, I added a back version of SDL to MinGW's include

Differences between boost::string_ref and boost::string_view

混江龙づ霸主 提交于 2021-02-18 05:11:53
问题 Boost provides two different implementations of string_view , which will be a part of C++17: boost::string_ref in utility/string_ref.hpp boost::string_view in core/string_view.hpp Are there any significant differences between these? Which should be preferred going forward? Note: I noticed in Boost 1.61, boost::log has deprecated string_ref in favor of string_view; perhaps that's an indicator? (http://www.boost.org/users/history/version_1_61_0.html) 回答1: Funnily enough right now I'm at the

cmake cannot find libraries installed with vcpkg

核能气质少年 提交于 2021-02-17 22:54:19
问题 I want to use vcpkg in a CMake project in Windows, because I need boost and xerces that are both handled by this package manager. I've the following CMakeLists.txt : cmake_minimum_required (VERSION 3.12.0) project (myproj) set (CMAKE_PREFIX_PATH ${XERCES_ROOT}) set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED ON) unset (Boost_INCLUDE_DIR CACHE) unset (Boost_LIBRARY_DIRS CACHE) # set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules) find_package (Boost COMPONENTS

Using futures with boost::asio

空扰寡人 提交于 2021-02-17 21:52:10
问题 Does anyone have a good pointer to examples which use futures from the Boost thread library with Boost ASIO? I have an existing asynchronous library which uses callback function that I would like to provide a friendlier synchronous interface for. 回答1: It is difficult to provide a concise solution without understanding the interactions with the existing asynchronous library. Nevertheless, this answer uses Boost.Future and Boost.Asio to implement an Active Object pattern. When creating a future

Boost parse_config_file, empty key value

删除回忆录丶 提交于 2021-02-17 21:35:24
问题 I am using Boost program_options to parse a config file in the standard way as shown in the multiple_sources.cpp example file of program_options. ifstream ini_file("config.ini"); po::store(po::parse_config_file(ini_file, desc, true), vm); po::notify(vm); The config.ini file however has empty key=value pairs such as: key1=value1 key2=value2 key3= key4= key5=value5 Trying to read this file results in a Boost error: boost::program_options::invalid_option_value Is there any mechanism in boost:

Boost parse_config_file, empty key value

北城以北 提交于 2021-02-17 21:34:33
问题 I am using Boost program_options to parse a config file in the standard way as shown in the multiple_sources.cpp example file of program_options. ifstream ini_file("config.ini"); po::store(po::parse_config_file(ini_file, desc, true), vm); po::notify(vm); The config.ini file however has empty key=value pairs such as: key1=value1 key2=value2 key3= key4= key5=value5 Trying to read this file results in a Boost error: boost::program_options::invalid_option_value Is there any mechanism in boost:

Creating own implementation of Boost::Archive

谁说胖子不能爱 提交于 2021-02-17 19:22:12
问题 I'm currently creating a concept which uses Boost::Serialization and which needs to implement its own Boost::Archive cause the data has to be serialized in a certain way. There is documentation about implementing custom archives in the documentation: http://www.boost.org/doc/libs/1_44_0/libs/serialization/doc/index.html But I'm curious if there are any other (reallife) examples anywhere on the net. I couldn't find any. Perhaps someone could point me to a source or article. 回答1: Example

Creating own implementation of Boost::Archive

瘦欲@ 提交于 2021-02-17 19:22:06
问题 I'm currently creating a concept which uses Boost::Serialization and which needs to implement its own Boost::Archive cause the data has to be serialized in a certain way. There is documentation about implementing custom archives in the documentation: http://www.boost.org/doc/libs/1_44_0/libs/serialization/doc/index.html But I'm curious if there are any other (reallife) examples anywhere on the net. I couldn't find any. Perhaps someone could point me to a source or article. 回答1: Example

is boost::property_tree::ptree thread safe?

放肆的年华 提交于 2021-02-17 15:14:36
问题 I'm using boosts read_json in a couple of threads in a piece of code. A simplified breakdown of the call is below. I'm getting segfaults in one of the threads (and sometimes the other) and it's making me think that read_json is not thread safe (Or I'm just using it in a dumb way) void someclass::dojson() { using boost::property_tree::ptree; ptree pt; std::stringstream ss(json_data_string); read_json(ss,pt); } Now json_data_string is different between the two classes (it's just json data

Why does libc++'s implementation of shared_ptr use full memory barriers instead of relaxed?

别说谁变了你拦得住时间么 提交于 2021-02-17 12:22:38
问题 In boost's implementation of shared_ptr , it uses relaxed memory ordering to increment its reference count. This appears safe as decrements use acquire/release to make sure that any previous decrements are visible to the thread before releasing memory. This method seems correct and appears in Herb Sutters talk on atomics In libc++'s implementation uses full memory barriers template <class T> inline T increment(T& t) _NOEXCEPT { return __sync_add_and_fetch(&t, 1); } template <class T> inline T