This is the mail archive of the gcc@gcc.gnu.org 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: [cxx-conversion] is enable_if ok?


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


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