From 7d980e44b255dd067c608726732aaf260da6187a Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 14 Jul 2015 10:38:30 -0700 Subject: Remove lambda function with lambda capture to allow building with pre-lambda compilers --- include/grpc++/impl/call.h | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'include/grpc++/impl') diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index 64fa5d6efb..2716bfe93a 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -172,17 +172,31 @@ class CallOpRecvMessage { grpc_byte_buffer* recv_buf_; }; +namespace CallOpGenericRecvMessageHelper { +class DeserializeFunc { + public: + virtual Status deser(grpc_byte_buffer* buf,int max_message_size) = 0; +}; + +template class DeserializeFuncType : public DeserializeFunc { + public: + DeserializeFuncType(R *message): message_(message) {} + Status deser(grpc_byte_buffer* buf,int max_message_size) { + return SerializationTraits::Deserialize(buf, message_, + max_message_size); + } + private: + R *message_; // Not a managed pointer because management is external to this +}; +}; // namespace CallOpGenericRecvMessageHelper + class CallOpGenericRecvMessage { public: CallOpGenericRecvMessage() : got_message(false) {} - template - void RecvMessage(R* message) { - deserialize_ = [message](grpc_byte_buffer* buf, - int max_message_size) -> Status { - return SerializationTraits::Deserialize(buf, message, - max_message_size); - }; + template void RecvMessage(R* message) { + deserialize_.reset(new CallOpGenericRecvMessageHelper:: + DeserializeFuncType(message)); } bool got_message; @@ -201,7 +215,7 @@ class CallOpGenericRecvMessage { if (recv_buf_) { if (*status) { got_message = true; - *status = deserialize_(recv_buf_, max_message_size).ok(); + *status = deserialize_->deser(recv_buf_, max_message_size).ok(); } else { got_message = false; grpc_byte_buffer_destroy(recv_buf_); @@ -210,12 +224,11 @@ class CallOpGenericRecvMessage { got_message = false; *status = false; } - deserialize_ = DeserializeFunc(); + deserialize_.reset(); } private: - typedef std::function DeserializeFunc; - DeserializeFunc deserialize_; + std::unique_ptr deserialize_; grpc_byte_buffer* recv_buf_; }; -- cgit v1.2.3