boost

boost python: tie lifetime of argument to returned value using return_internal_reference

只愿长相守 提交于 2021-02-07 09:16:23
问题 I begin learning to use boost python and have a rookie question. I would like to write a function that can tie the lifetime of its argument to its results, such that when I call r = func(a) , the argument a will never be destroyed if I still have a reference of r . The documentation suggests using return_internal_reference call policy for this type of request. But does this require r to be an internal reference of a , as the name suggested? In the (over-simplified) example below, suppose I

boost file_mapping performance

若如初见. 提交于 2021-02-07 08:47:24
问题 I wrote a small test to compare file writing operations between boost file_mapping and std::ofstream . I was under the impression that file_mapping performance would be superior but it is apparently not the case. Can someone explain why I would get better numbers with std::ofstream ? [EDIT]: So I did a profiling of my benchmark test and noticed that boost::iostreams::detail::direct_streambuf was spending lots of time copying bytes. I've added a new test which is using std::copy_n instead of

boost file_mapping performance

末鹿安然 提交于 2021-02-07 08:43:54
问题 I wrote a small test to compare file writing operations between boost file_mapping and std::ofstream . I was under the impression that file_mapping performance would be superior but it is apparently not the case. Can someone explain why I would get better numbers with std::ofstream ? [EDIT]: So I did a profiling of my benchmark test and noticed that boost::iostreams::detail::direct_streambuf was spending lots of time copying bytes. I've added a new test which is using std::copy_n instead of

Boost spirit get the whole match as a string

让人想犯罪 __ 提交于 2021-02-07 07:09:58
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I

Boost spirit get the whole match as a string

社会主义新天地 提交于 2021-02-07 07:08:50
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I

Boost spirit get the whole match as a string

落爺英雄遲暮 提交于 2021-02-07 07:08:36
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I

C++ Boost.Python : 2 problems

半城伤御伤魂 提交于 2021-02-07 07:08:32
问题 So, i search good tool to integrate my C++ code with python, and at first i looked at boost.python. I've get hello examle from boost documentation and try to build and run it. Source code is (src/hello.cpp): #include <Python.h> #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Problem 1 - Windows and mingw I try to build and my result : g++ -o build\hello.o -c -IE:\Programming\libs

Boost spirit get the whole match as a string

荒凉一梦 提交于 2021-02-07 07:08:17
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I

Boost spirit get the whole match as a string

孤街浪徒 提交于 2021-02-07 07:08:09
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I

Boost spirit get the whole match as a string

青春壹個敷衍的年華 提交于 2021-02-07 07:07:56
问题 I'm trying to define my own grammar using boost spirit framework and I'm defining such a matching rule: value = ( char_('"') >> (*qi::lexeme[ char_('\\') >> char_('\\') | char_('\\') >> char_('"') | graph - char_('"') | char_(' ') ])[some_func] >> char_('"') ); I'd like to assing an action - some_func - to the part of it, and pass the whole matching string as a parameter. But unfortunately I will get something like vector<boost::variant<boost::fusion::vector2 ..a lot of stuff...)...> . Can I