I don't know of any way to do exactly what you're trying to do in that code.
 Sorry.

On Thu, May 6, 2010 at 4:17 AM, Adagio Grazioso <adagiograzi...@gmail.com>wrote:

> Kenton,
>
> How do I make the following usage compile correctly?
>
> <code>
> $ cat test.proto
>
> message Base {
>     optional uint32 a = 1;
>     optional uint32 b = 2;
>
>     extensions 100 to 200;
> }
>
> message Ext {
>     optional uint32 x = 1;
>     optional uint32 y = 2;
> }
>
> extend Base {
>     optional Ext ext = 100;
> }
>
> $ cat test.cc
> #include "test.pb.h"
>
> template <typename extid>
> class Test {
> public:
>     Test() {
>       assert(t.HasExtension(extid) == false);
>     }
> private:
>     Base t;
> };
>
> Test<ext> mt;
> </code>
>
> Adagio
>
> On Mon, May 3, 2010 at 10:59 PM, Kenton Varda <ken...@google.com> wrote:
>
>> The only safe way to do this is to not depend on the type of the extension
>> ID at all.  For example:
>>
>> template <typename T>
>> void foo(Message* message, const T& extension_id) {
>>   message->SetExtension(extension_id, 123);
>> }
>>
>> On Sat, May 1, 2010 at 5:30 AM, Adagio <adagiograzi...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Is it possible to use extension id as a parameter to C++ templates?
>>>
>>> If yes, should it be declared as a pointer/reference to a object
>>> (seeing that the extension identifier is actually a global object)?
>>> (an example would help very much!)
>>>
>>> Finally is it future-safe considering ExtensionIdentifier is in the
>>> google::protobuf::internal namespace?
>>>
>>> Adagio
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Protocol Buffers" group.
>>> To post to this group, send email to proto...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/protobuf?hl=en.
>>>
>>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to