This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using C++ in GCC is OK

Now that we are talking about STL & templates: What about boost?

On Wed, Jun 2, 2010 at 11:22 AM, Gabriel Dos Reis
<> wrote:
> On Wed, Jun 2, 2010 at 9:05 AM, Paolo Bonzini <> wrote:
>> On 06/02/2010 03:01 PM, Gabriel Dos Reis wrote:
>>> In the guidelines, I would like to include:
>>> Â Â(2) if you define a class template used mostly with pointer type
>>> arguments,
>>> Â Â Â Â consider specializing for void* (or const void*) and define all
>>> other
>>> Â Â Â Â pointer specialization in terms of that.
>> I have no idea what you're saying. :-) ÂWhat do you mean by "define all
>> other pointer specialization in terms of that"? ÂWouldn't specializing on T*
>> just work?
> yes, it would work, but it may duplicate same executable several times
> for those concerned about code size.
> Imagine a vector class template
> Â Â Âtemplate<typename T> struct Vec; Â Â// primary template
> Â Â Â// specialize for T=void*
> Â Â Âtemplate<>
> Â Â Â Â struct Vec<void*> {
> Â Â Â Â Â Â void* get(int i) { .... }
> Â Â Â Â Â Â // ...
> Â Â Â Â };
> Â Â Â// specialize all T* in terms of void*
> Â Â Âtemplate<typename T>
> Â Â Â Â struct Vec<T*> : private Vec<Void*> {
> Â Â Â Â Â Âtypedef Vec<Void*> Impl;
> Â Â Â Â Â Â// define all operations in as forwarding functions to Impl
> Â Â Â Â Â ÂT* get(int i) { return static_cast<T*>(Impl::get(i));
> Â Â Â Â Â Â// and so on.
> Â Â Â Â };
> you only have one "ultimate" implementation, all others being simple inline
> fowarding functions. ÂThis is for people concerned about code size.

Emilio Wuerges
LAPS - Laboratorio de Automacao de Projeto de Sistemas
UFSC - Universidade Federal de Santa Catarina

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]