boost

How do I pass protobuf's boost::shared_ptr pointer to function?

邮差的信 提交于 2020-01-24 17:07:10
问题 I have to pass a boost::shared_ptr : boost::shared_ptr<Protobuf::Person::Profile> pProfile = boost::make_shared<Protobuf::Person::Profile>(); which is protobuf's pointer, to a protobuf's function oPerson.set_allocated_profile(pProfile) but oPerson.set_allocated() expects a pointer to Protobuf::Person::Profile . I have tried couple of ways but I think when I try to convert protobuf object to JSON using pbjson::pb2Json which is a library function built on rapid json, the pointer goes out of

How do I pass protobuf's boost::shared_ptr pointer to function?

馋奶兔 提交于 2020-01-24 17:06:26
问题 I have to pass a boost::shared_ptr : boost::shared_ptr<Protobuf::Person::Profile> pProfile = boost::make_shared<Protobuf::Person::Profile>(); which is protobuf's pointer, to a protobuf's function oPerson.set_allocated_profile(pProfile) but oPerson.set_allocated() expects a pointer to Protobuf::Person::Profile . I have tried couple of ways but I think when I try to convert protobuf object to JSON using pbjson::pb2Json which is a library function built on rapid json, the pointer goes out of

spirit x3 cannot propagate attributes of type optional<vector>

六月ゝ 毕业季﹏ 提交于 2020-01-24 15:48:47
问题 A simple parser as on Coliru. The parser -(+x3::alpha) should be able to propagate an attribute of type boost::optional<std::string> as Qi does. But it does not compile. std::string const input = "abc"; boost::optional<std::string> attr; if(x3::parse(boost::begin(input),boost::end(input), -(+x3::alpha), attr)) { std::cout<<"match!"<<std::endl; } else { std::cout<<"NOT match!"<<std::endl; } 回答1: I don't think the normative claim "should be able [...] as Qi does" cuts wood. X3 is not an

Efficiently read a portion of text in C++

纵然是瞬间 提交于 2020-01-24 13:12:07
问题 I've read this and then this questions about how to efficiently read big amount of text (floats in the second question) in C++ exploiting the boost::spirit library. From what I've seen, the solutions proposed in the questions above read the whole text, while I need to read a portion of the input text (for example from char x to char y). Can I exploit the library above for this purpose? How could I efficiently do it otherwise? 回答1: You don't even need to map a subsection of the file, because

udp client sever changing from pull model to push model [closed]

◇◆丶佛笑我妖孽 提交于 2020-01-24 12:58:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have implemented udp_client and 'udp_server` where server and client follows a pull model. The server pushes the data only when the client requests it. I want to change this to push model where server pushes the data down to the client when data is available. My source files, header files and make is given

Obtaining the type-name of a template type, without class definition

被刻印的时光 ゝ 提交于 2020-01-24 12:19:27
问题 I am trying to write a template wrapper that works with the smart_ptr type and need to throw an exception in some cases. For this case I'd like to include the name of the type the class is wrapping. As I am working with smart pointers only forward declarations will be available for the type. So the essential question is how can I get a string for of a template parameter without having its definition available? (I don't need a clean name, anything resembling the name will be fine) My attempt

Obtaining the type-name of a template type, without class definition

孤街浪徒 提交于 2020-01-24 12:19:26
问题 I am trying to write a template wrapper that works with the smart_ptr type and need to throw an exception in some cases. For this case I'd like to include the name of the type the class is wrapping. As I am working with smart pointers only forward declarations will be available for the type. So the essential question is how can I get a string for of a template parameter without having its definition available? (I don't need a clean name, anything resembling the name will be fine) My attempt

TypeError: No to_python (by-value) converter found for C++ type

半腔热情 提交于 2020-01-24 01:46:25
问题 I'm trying to expose my C++ Classes to Python using Boost.Python. Here is a simplyfied version of what I'm trying to do: struct Base { virtual ~Base() {}; virtual char const *Hello() { printf("Base.Hello\n"); return "Hello. I'm Base."; }; }; struct Derived : Base { char const *Hello() { printf("Derived.Hello\n"); return "Hello. I'm Derived."; }; Base &test() { printf("Derived.test\n"); // ... // After some calculation, we get result reference `instance' // `instance' can be an instance of

how to install boost correctly

天大地大妈咪最大 提交于 2020-01-24 01:00:29
问题 I've downloaded boost_1_61_0 and unzipped it. I used bootstrap.bat generating b2.exe and bjam.exe and successfully built libraries in a folder named "stage" for both x64 and win32 . After I have .lib and boost folders containing include files. When I remove the root folder I can't build my program. Why am I unable to build the code? I have used bs as: b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage -

What's the difference between using boost::equality_comparable<T> versus overriding bool operator ==?

喜夏-厌秋 提交于 2020-01-24 00:37:06
问题 When would I use boost::equality_comparable vs overriding T's bool operator==(T const& rhs) method? Here's some sample code. #include <boost/operators.hpp> enum class AnEnum : uint64_t; struct Base : boost::equality_comparable<Base> { std::shared_ptr<AnEnum > units; std::shared_ptr<int> value; bool operator ==(Base const& rhs) { return (*value == *rhs.value) && (*units == *rhs.units); } friend bool operator == (const Base & lhs, const Base & rhs) { return (*lhs.value == *rhs.value) && (*lhs