Re: [protobuf] template/type deduction and 'oneof' in message

2016-05-19 Thread 'Adam Cozzette' via Protocol Buffers
I don't think this kind of type deduction is possible here, because the type of the oneof can't be known until runtime and so the compiler has no way of knowing which function to select. Alex, I believe the convert example at the top of your link works but only because the caller explicitly

Re: [protobuf] template/type deduction and 'oneof' in message

2016-05-19 Thread Alex Shaver
So, the cpprefernce page on template type deduction seemingly suggests you can: http://en.cppreference.com/w/cpp/language/template_argument_deduction On Thu, May 19, 2016, 6:09 PM Feng Xiao wrote: > > > On Thu, May 19, 2016 at 10:31 AM, Alex Shaver >

Re: [protobuf] template/type deduction and 'oneof' in message

2016-05-19 Thread 'Feng Xiao' via Protocol Buffers
On Thu, May 19, 2016 at 10:31 AM, Alex Shaver wrote: > Suppose I have a message: > message Foo{ > oneof b_message { > Bar = 16; > Baz = 17; > } > } > > and I have some C++ handler that is a templated function: > template > void b_handler(const T&); > template

[protobuf] template/type deduction and 'oneof' in message

2016-05-19 Thread Alex Shaver
Suppose I have a message: message Foo{ oneof b_message { Bar = 16; Baz = 17; } } and I have some C++ handler that is a templated function: template void b_handler(const T&); template void b_handler(const Bar& bar){...} template void b_handler(const Baz& baz){...} What I'd like to