boost

C ++ Boost Bind Performance

流过昼夜 提交于 2020-01-13 09:47:05
问题 Are there any performance impacts (positive or negative) when binding functions (using Boost Bind) ? 回答1: Maybe, may not be. It depends. The result of std::bind (or also boost::bind ) is a so-called "bind expression", which has an un­know­able type determined by the implementation. This type is a Callable , and it is convertible to an in­stance of std::function (or boost::function ). Internally, function (may) use type erasure to handle various complex, stateful "call­able objects". This

Linker error - Undefined symbols std::string::c_str() const on macos with libboost_thread?

百般思念 提交于 2020-01-13 09:43:46
问题 I installed boost 1.55.0 from homebrew on macos mavericks. Getting a linker exception - not finding std::string::c_str() which I don't understand why. Could this be a problem with homebrew? I tried compiling boost 1.55.0 directly from boost and it doesn't even build on macos. This little bit of code: #include <iostream> #include <unordered_map> #include <vector> #include <boost/thread/tss.hpp> typedef std::unordered_map<std::string, std::string> StringMap; static boost::thread_specific_ptr

Linker error - Undefined symbols std::string::c_str() const on macos with libboost_thread?

北城以北 提交于 2020-01-13 09:43:31
问题 I installed boost 1.55.0 from homebrew on macos mavericks. Getting a linker exception - not finding std::string::c_str() which I don't understand why. Could this be a problem with homebrew? I tried compiling boost 1.55.0 directly from boost and it doesn't even build on macos. This little bit of code: #include <iostream> #include <unordered_map> #include <vector> #include <boost/thread/tss.hpp> typedef std::unordered_map<std::string, std::string> StringMap; static boost::thread_specific_ptr

Linker error - Undefined symbols std::string::c_str() const on macos with libboost_thread?

一曲冷凌霜 提交于 2020-01-13 09:42:33
问题 I installed boost 1.55.0 from homebrew on macos mavericks. Getting a linker exception - not finding std::string::c_str() which I don't understand why. Could this be a problem with homebrew? I tried compiling boost 1.55.0 directly from boost and it doesn't even build on macos. This little bit of code: #include <iostream> #include <unordered_map> #include <vector> #include <boost/thread/tss.hpp> typedef std::unordered_map<std::string, std::string> StringMap; static boost::thread_specific_ptr

Traversing a boost::ublas matrix using iterators

廉价感情. 提交于 2020-01-13 09:17:05
问题 I simply want to traverse a matrix from start to finish touching upon every element. However, I see that there is no one iterator for boost matrix, rather there are two iterators, and I haven't been able to figure out how to make them work so that you can traverse the entire matrix typedef boost::numeric::ublas::matrix<float> matrix; matrix m1(3, 7); for (auto i = 0; i < m1.size1(); i++) { for (auto j = 0; j < m1.size2(); j++) { m1(i, j) = i + 1 + 0.1*j; } } for (auto itr1 = m1.begin1(); itr1

How to export std::vector

天大地大妈咪最大 提交于 2020-01-13 08:23:09
问题 I'm writing application wiht boost.python library. I want to pass function into python which returnes std::vector . I have a little troubles: inline std::vector<std::string> getConfigListValue(const std::string &key) { return configManager().getListValue(key); } BOOST_PYTHON_MODULE(MyModule) { bp::def("getListValue", getListValue); } When I call that function from python I get: TypeError: No to_python (by-value) converter found for C++ type: std::vector<std::string, std::allocator<std::string

Building Boost dynamically linkable gives linking error?

最后都变了- 提交于 2020-01-13 07:49:42
问题 I am trying to build boost and generate dll's but whatever I have done did not solve the problem. Here what I have got: Creating library bin.v2\libs\thread\build\msvc-11.0\dbg\adrs-mdl-32\async-excpt-on\thrd-mlt\boost_thread-vc110-mt-gd-1_53.lib and object bin.v2\libs\thread\build\msvc-11.0\dbg\adrs-mdl-32\async-excpt-on\thrd-mlt\boost_thread-vc110-mt-gd-1_53.exp thread.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::greg

Library for saving c++ objects to database

核能气质少年 提交于 2020-01-13 06:06:49
问题 I am currently saving my object graph in xml file with boost serialization. The library is great, it automatically restores the objects and all member pointers and references. Problem : I need to have random access to the data ( read just one object, or delete just one object ). With boost serialization the scenario is like this : --load all objects from file -- use and modify objects -- write all objects to archive again The drawback with this is if only one object changed , I want to write

Set a python variable to a C++ object pointer with boost-python

你说的曾经没有我的故事 提交于 2020-01-13 05:34:08
问题 I want to set a Python variable from C++ so that the C++ program can create an object Game* game = new Game(); in order for the Python code to be able to reference this instance (and call functions, etc). How can I achieve this? I feel like I have some core misunderstanding of the way Python or Boost-Python works. The line main_module.attr("game") = game is in a try catch statement, and the error (using PyErr_Fetch) is "No to_python (by-value) converter found for C++ type: class Game". E.g.

Initializing boost::asio sockets after constructor

元气小坏坏 提交于 2020-01-13 05:31:12
问题 [Update:] The answer for whoever is interested, is simply wrapping the io_service member var in boost::ref (boost::ref(io_service_)) I am experimenting with the udp server example from boost asio libraries, to see if I can initialize the socket somewhere other than in the constructor. The constructor proposed in the example is the following: class server { public: server(boost::asio::io_service& io_service, short port) : io_service_(io_service), socket_(io_service, udp::endpoint(udp::v4(),