boost

Extract in C++ a Python object inherited from C++ Class

一笑奈何 提交于 2021-02-08 06:39:04
问题 I want to export an abstract class from C++(Base) to create an inherited class in Python(Derived) and finally extract that class for create a C++ pointer object(Base*). I find this solution. but it didn't work for me although it compiles, the execution halt with an exception. My code is this: #if PY_MAJOR_VERSION >= 3 # define INIT_MODULE PyInit_module extern "C" PyObject* INIT_MODULE(); #else # define INIT_MODULE initmodule extern "C" void INIT_MODULE(); #endif int main() { PyImport

Extract in C++ a Python object inherited from C++ Class

我与影子孤独终老i 提交于 2021-02-08 06:38:07
问题 I want to export an abstract class from C++(Base) to create an inherited class in Python(Derived) and finally extract that class for create a C++ pointer object(Base*). I find this solution. but it didn't work for me although it compiles, the execution halt with an exception. My code is this: #if PY_MAJOR_VERSION >= 3 # define INIT_MODULE PyInit_module extern "C" PyObject* INIT_MODULE(); #else # define INIT_MODULE initmodule extern "C" void INIT_MODULE(); #endif int main() { PyImport

Parse OBJ file with mixed data-types using Boost.Spirit?

不问归期 提交于 2021-02-08 06:17:15
问题 I do have an OBJ file that looks like this: # This file uses centimeters as units for non-parametric coordinates. # first element v -0.017050 -0.017928 0.005579 v -0.014504 -0.017928 0.010577 . . v -0.000000 -0.017928 0.017967 vt 0.397581 0.004762 vt 0.397544 0.034263 . . vt 0.397507 0.063764 vn -0.951057 0.000000 0.309016 vn -0.809017 0.000000 0.587785 . . vn -0.587785 0.000000 0.809017 f 1/1/1 2/2/2 21/4/3 f 21/4/3 2/2/2 22/3/4 . . f 3/5/5 4/7/7 23/6/6 # second element v -0.014504 0.017928

Questions with using boost for generating normal random numbers

邮差的信 提交于 2021-02-08 04:01:54
问题 I was hoping to learning how to generate numbers from normal distribution in C++ when I saw This Post. It gives a very good example, but still I am not sure what the & in boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng, nd); means. What effect will it produce if I did not include this & here? Also, when reading the tutorial on Boost's official website, I found that after generating a distribution object with boost::random::uniform_int_distribution<> dist(1

Boost mapped_file_source, alignment and page size

不问归期 提交于 2021-02-08 02:11:53
问题 I'm trying to parse some text files of size up to a few hundred megabytes in a context where performance is important, so I'm using boost mapped_file_source. The parser expects the source to be terminated with a null byte, so I want to check whether the file size is an exact multiple of the page size (and if so, fall back on a slower, non-memory mapped method). I thought I could do this with: if (mf.size() & (mf.alignment() - 1)) But it turns out on one test file with size 20480, the

Boost mapped_file_source, alignment and page size

只愿长相守 提交于 2021-02-08 02:06:55
问题 I'm trying to parse some text files of size up to a few hundred megabytes in a context where performance is important, so I'm using boost mapped_file_source. The parser expects the source to be terminated with a null byte, so I want to check whether the file size is an exact multiple of the page size (and if so, fall back on a slower, non-memory mapped method). I thought I could do this with: if (mf.size() & (mf.alignment() - 1)) But it turns out on one test file with size 20480, the

Loading CA certificate from memory

ぃ、小莉子 提交于 2021-02-08 02:00:46
问题 I am trying to load CA certificate from memory instead of file. But I keep getting handshake error while connecting. The file loading works perfectly, memory loading fails. What am I missing? std::ifstream file("message_server_ca.crt"); std::vector<char> fileContents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); boost::asio::const_buffer buffer(&fileContents.at(0),fileContents.size()); bool useFile = false; // switch between file and memory loading. boost::asio:

Loading CA certificate from memory

∥☆過路亽.° 提交于 2021-02-08 02:00:19
问题 I am trying to load CA certificate from memory instead of file. But I keep getting handshake error while connecting. The file loading works perfectly, memory loading fails. What am I missing? std::ifstream file("message_server_ca.crt"); std::vector<char> fileContents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); boost::asio::const_buffer buffer(&fileContents.at(0),fileContents.size()); bool useFile = false; // switch between file and memory loading. boost::asio:

How to use boost::serialization with nested structs and minimal code changes?

 ̄綄美尐妖づ 提交于 2021-02-07 23:55:23
问题 Currently we use POD which is stored in nested structs. Example: #define MaxNum1 100; #define MaxNum2 50; struct A { int Value[MaxNum1]; char SomeChar = 'a'; }; struct B { A data[MaxNum2]; float SomeFloat = 0.1f; }; int main() { B StructBObject = {}; } We want to enhance our data structures using std::vector just like this: struct NewA { std::vector<int> Value; char SomeChar = 'a'; }; struct NewB { std::vector<NewA> data; float SomeFloat = 0.1f; }; int main() { NewB StructNewBObject = {}; }

Pickling a vector in boost python?

独自空忆成欢 提交于 2021-02-07 18:17:43
问题 I have this simple C++ code: class Contained {}; class CannotPickle { public: CannotPickle() {}; CannotPickle(std::vector<boost::shared_ptr<Contained>> new_vector) : my_vector(new_vector) {}; std::vector<boost::shared_ptr<Contained>> my_vector; }; struct CannotPickle_pickle_suite : boost::python::pickle_suite { static boost::python::tuple getinitargs(CannotPickle const& c) { return boost::python::make_tuple(c.my_vector); } }; I'm trying to enable pickling support for CannotPickle like this: