diff options
author | Nicolas "Pixel" Noble <nicolas@nobis-crew.org> | 2015-05-02 01:07:07 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <nicolas@nobis-crew.org> | 2015-05-02 01:07:10 -0700 |
commit | 99076fe593c95bc7bae490d920c4c85606c25f69 (patch) | |
tree | 659a92a4585dcd762cf47e5f95f2763487099dc3 | |
parent | df3c6c55b0f511dd910fc7ee68d9fcb926e5c63d (diff) |
Fixing generated code under Windows.
By the standard, std::function can only capture class functions, and not
class methods. For some reasons, this works under gcc however. Visual
Studio rejects it. std::mem_fn is proper template to use.
-rw-r--r-- | src/compiler/cpp_generator.cc | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 1324198847..735e7e58a8 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -828,9 +828,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer, " new ::grpc::RpcMethodHandler< $ns$$Service$::Service, " "$Request$, " "$Response$>(\n" - " std::function< ::grpc::Status($ns$$Service$::Service*, " - "::grpc::ServerContext*, const $Request$*, $Response$*)>(" - "&$ns$$Service$::Service::$Method$), this),\n" + " std::mem_fn(&$ns$$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } else if (ClientOnlyStreaming(method)) { printer->Print( @@ -840,10 +838,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer, " ::grpc::RpcMethod::CLIENT_STREAMING,\n" " new ::grpc::ClientStreamingHandler< " "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::function< ::grpc::Status($ns$$Service$::Service*, " - "::grpc::ServerContext*, " - "::grpc::ServerReader< $Request$>*, $Response$*)>(" - "&$ns$$Service$::Service::$Method$), this),\n" + " std::mem_fn(&$ns$$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -853,10 +848,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer, " ::grpc::RpcMethod::SERVER_STREAMING,\n" " new ::grpc::ServerStreamingHandler< " "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::function< ::grpc::Status($ns$$Service$::Service*, " - "::grpc::ServerContext*, " - "const $Request$*, ::grpc::ServerWriter< $Response$>*)>(" - "&$ns$$Service$::Service::$Method$), this),\n" + " std::mem_fn(&$ns$$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } else if (BidiStreaming(method)) { printer->Print( @@ -866,10 +858,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer, " ::grpc::RpcMethod::BIDI_STREAMING,\n" " new ::grpc::BidiStreamingHandler< " "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::function< ::grpc::Status($ns$$Service$::Service*, " - "::grpc::ServerContext*, " - "::grpc::ServerReaderWriter< $Response$, $Request$>*)>(" - "&$ns$$Service$::Service::$Method$), this),\n" + " std::mem_fn(&$ns$$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } } |