boost

C++ How to set a severity filter on a Boost Global Logger

99封情书 提交于 2020-01-30 05:11:55
问题 I've been trying for days now to create a Boost Global Logger for use throughout the application but I can't seem to get the severity level set in the Global Logger . IMPORTANT: Look below for Andrey's answer...it's labeled as step (a) and (b) but I'm still not getting it right! Right out of the Boost Documentation here ...it would be more convenient to have one or several global loggers in order to easily access them in every place when needed. In this regard std::cout is a good example of

How to compile Boost multithreaded program?

不羁的心 提交于 2020-01-28 10:55:13
问题 I installed boost library. Everything is going OK without multithreading. How do i compile this test program ? #include <boost/thread/thread.hpp> #include <iostream> using namespace std; void hello_world() { cout << "I'm new thread!" << endl; } int main(int argc, char* argv[]) { boost::thread my_thread(&hello_world); my_thread.join(); return 0; } I used: g++ -I/home/user/boost/include testc.cpp but g++ show me: /tmp/ccQtBeSf.o: In function `main': testc.cpp:(.text+0x5a): undefined reference

Boost.Python tries to link against python27.lib using Visual C++

我是研究僧i 提交于 2020-01-25 10:51:07
问题 I'm trying to build boost python using Python 3.2. I'm linking against python32.lib and libboost_python3-vc110-mt-gd-1_52.lib. I also definied BOOST_ALL_NO_LIB to disable boost's auto link feature. Still I'm getting the following error: fatal error LNK1104: cannot open file 'python27.lib' How to tell boost to use Python 3.2? 回答1: Do you have multiple Python installations on your computer? You probably have to create a user-config.jam file with content like this: using python : 3.2 : C:\Path

assign multiple values to boost::numeric::ublas::vector in c++

此生再无相见时 提交于 2020-01-25 10:32:47
问题 I want to know how I can assign multiple values to a vector at once: #include <iostream> #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/io.hpp> using namespace boost::numeric::ublas; int main() { vector<double> v1(3); v1(0)=0; v1(1)=0.1; v1(2)=0.05; v1(3)=0.25; return 0; } I want to assign all the values at once. something like: v1 << 0,0.1,0.05,0.25; I tried operator += and there is an error, but I think operator += works for std::vector not boost::....vector 回答1:

C++ and Boost.Python - how to expose variable to python and update it in loop?

坚强是说给别人听的谎言 提交于 2020-01-25 06:52:52
问题 Introduction I have a python code called from c++, using boost.python package. I can pass some variables, when calling MyFunc from .py like this: Py_SetPythonHome(pySearchPath); try { Py_Initialize(); numpy::initialize(); object module = import("__main__"); object name_space = module.attr("__dict__"); exec(python_full, name_space, name_space); object MyFunc = name_space["MyFunc"]; object result = MyFunc(var1, var2, var3)); //HERE //Python results storage numpy::ndarray ret = extract<numpy:

ublas: Wrap ublas::vector as ublas::matrix_expression

邮差的信 提交于 2020-01-25 02:57:26
问题 I'm a very noob at Boost::uBLAS. I have a function which take a ublas::matrix_expression<double> as input: namespace ublas = boost::numeric::ublas; void Func(const ublas::matrix_expression<double>& in, ublas::matrix_expression<double>& out); A caller is holding a row vector as ublas::vector<double> , and I want it to be passed to Func . Until now I have not found any way to do this. What is the best way, preferably without any temporary allocation? Thanks. 回答1: Well, there is an option to

Fastest method of accessing elements in Boost MultiArray

偶尔善良 提交于 2020-01-24 22:53:04
问题 What is faster - accessing elements of a multiarray using element selection operator, or traversing over the multiarray using iterators? In my case, I need to do a full pass over all elements of multiarray each time. 回答1: The fastest way to access every element of a boost::multi_array is via data() and num_elements() . With data() you gain access to the underlying raw storage (a contiguous block that contains the array‘s data) so there isn't need for multiple index calculations (consider also

CMake boost imported targets

家住魔仙堡 提交于 2020-01-24 21:34:08
问题 Can you explain me how should I use something like Boost::headers in my CMake file? I tried to utilize it somehow but is seems to work in different manner than I understand it. cmake_minimum_required(VERSION 3.15) project(Test) find_package(Boost COMPONENTS asio REQUIRED) add_executable(test main.cpp) target_include_directories(test SYSTEM PUBLIC ${Boost_INCLUDE_DIR}) target_link_libraries(test PUBLIC Boost::headers) This example does not work. It is caused by COMPONENTS asio . ASIO seems to

How can I solve this error in Printing Nodes and Edges Boost Graph Library?

纵然是瞬间 提交于 2020-01-24 20:47:08
问题 I have written the following function to print out just the size of My Graph Nodes and Edges, but this function didn't work, the Error was : error: invalid use of non-static data member 'MyGraph' typedef adjacency_list < vecS, vecS, directedS, property < vertex_name_t, idType >, property < edge_weight_t, double > > graph_t; class MyGraphBuilder{ private: graph_t MyGraph; } void MyGraphBuilder::printGraph(MyGraphBuilder::MyGraph){ unsigned long long NodesCount = num_vertices(MyGraphBuilder:

boost::shared_ptr and Return Type Resolver idiom

冷暖自知 提交于 2020-01-24 17:07:27
问题 I am currently working on a concept of Object known in Java or C# for C++. It would be similar to variant type like boost::any, however having wider functionality. For that purpose I am using boost::shared_ptr to internaly store actual data and I wanted to provide Return Type Resolver idiom for easily obtaining this data, as it is stored in actual implementation. I know I could use boost::shared_ptr automatic conversion during assigment operator or constructor but as I said shared_ptr is not