Re: [protobuf] Can protobuf work with C++ templates?

2019-05-17 Thread Jui
Yeah this actually makes sense. I just want to make sure I did not miss anything. Thanks. On Friday, May 17, 2019 at 1:40:59 PM UTC-7, Adam Cozzette wrote: > > No, there is not really any good alternative but to write two separate > message definitions. The .proto file format is

Re: [protobuf] Can protobuf work with C++ templates?

2019-05-17 Thread 'Adam Cozzette' via Protocol Buffers
No, there is not really any good alternative but to write two separate message definitions. The .proto file format is language-agnostic so it can't use any C++-specific features. On Thu, May 16, 2019 at 9:37 PM Jui-Hsien Wang wrote: > I am revoking this old question but I would like to know if

Re: [protobuf] Can protobuf work with C++ templates?

2019-05-16 Thread Jui-Hsien Wang
I am revoking this old question but I would like to know if protobuf can handle class templates? Suppose I have a simple class template struct Data { T data; }; and know that T can only take on float and double. Is there a way to avoid writing two proto files? On Wednesday, January 21,

Re: [protobuf] Can protobuf work with C++ templates?

2015-01-21 Thread Stephen Tu
This is not really a protobuf question, moreso a C++ question. But anyways, the typical way to do this is: template typename T struct MatrixTraits { }; template struct MatrixTraitsdouble { typedef DoubleMatrix type; }; template struct MatrixTraitsfloat{ typedef FloatMatrix type; };

Re: [protobuf] Can protobuf work with C++ templates?

2015-01-21 Thread Ji Wan
Got a new skill :P Thanks very much! --- Original Message --- From: Stephen Tu tu.steph...@gmail.com Sent: January 22, 2015 1:28 AM To: Ji Wan wa...@live.com Cc: protobuf@googlegroups.com Subject: Re: [protobuf] Can protobuf work with C++ templates? This is not really a protobuf question

[protobuf] Can protobuf work with C++ templates?

2015-01-20 Thread Ji Wan
Suppose I have two message types `DoubleMatrix` and `FloatMatrix`, and a template class `Matrix`: message DoubleMatrix { required uint32 rows = 1; required uint32 cols = 2; repeated double data = 3 [packed=true]; } message FloatMatrix { required uint32 rows = 1; required uint32