This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [cxx-conversion] is enable_if ok?
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Pedro Lamarão <pedro dot lamarao at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 14 Apr 2012 22:40:46 +0200 (CEST)
- Subject: Re: [cxx-conversion] is enable_if ok?
- References: <jmckkf$vdm$1@dough.gmane.org>
- Reply-to: gcc at gcc dot gnu dot org
On Sat, 14 Apr 2012, Pedro Lamarão wrote:
Hello,
currently proposed C++ Coding Conventions imply a very strict
weird-is-forbidden style, which I like.
But if defining new templates should in general be avoided, I'm unsure what
is the best path in converting VEC.
VEC interface optimizes element acessors to copy primitive types and point-to
object types.
If VEC is to be a template class, default accessors in C++ would naturally
return a (const-)reference-to anything. It would be possible to optimize
accessors to return a copy instead of a const-reference-to with enable_if.
All this would allow VEC to be mostly just one thing, with small variations
in corresponding to VEC_last and VEC_index.
Do you seriously expect it to make a difference? Accessors should be
inlined to the point of making the value/reference thing irrelevant. If
std::vector suffers a performance penalty because of this, it is a serious
optimizer deficiency that should be fixed so all C++ users can benefit.
--
Marc Glisse