Closed Bug 763604 Opened 12 years ago Closed 12 years ago

Use typename for type parameters of template template parameters in BindingUtil.h

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: bjacob, Assigned: bjacob)

Details

Attachments

(2 files)

What I really wanted to fix was this:

  template<class T, template<class> class SmartPtr>

which is IMO more readable as:

  template<typename T, template<typename> class SmartPtr>

Also, this file already uses typename for certain type template params, and sometimes mixes typename and class in the same line, like:

  template <class T, typename U>

Maybe this was intentional as this T can't be a non-class type, but in that case I'd argue that this gives the wrong impression that this would guarantee this.
Attachment #631969 - Flags: review?(Ms2ger)
Attachment #631969 - Flags: review?(Ms2ger) → review?(khuey)
> Maybe this was intentional as this T can't be a non-class type

It sort of was, yes.  In particular, it needs to be a type for which PrototypeIDMap has a specialization, and those are only generated for (some) classes.

I don't object to using "typename" here, I guess, but I did slightly like the "self-documenting" aspect of "class" there.
Comment on attachment 631969 [details] [diff] [review]
use typename everywhere

I'm going to let you work this out with bz.
Attachment #631969 - Flags: review?(khuey) → review?(bzbarsky)
(In reply to Boris Zbarsky (:bz) from comment #1)
> > Maybe this was intentional as this T can't be a non-class type
> 
> It sort of was, yes.  In particular, it needs to be a type for which
> PrototypeIDMap has a specialization, and those are only generated for (some)
> classes.
> 
> I don't object to using "typename" here, I guess, but I did slightly like
> the "self-documenting" aspect of "class" there.

My main concern with this is that most of the time when class is used instead of typename, it's interchangeably, so the uses of class here don't self-document much for the average reader (who doesn't know about your intention here). On the other hand, the cost in terms of readability in 

  template<class T, template<class> class SmartPtr>

is real IMO.

But this isn't very important so I guess I'll WONTFIX this if we can't agree now that this is a clear improvement.
Comment on attachment 631969 [details] [diff] [review]
use typename everywhere

Oh, I agree the "template<typename> class SmartPtr" bit is much better, and we should do that part.  And like I said, I can live with the rest...  

r=me, though if you want to just fix the "template<typename> class SmartPtr" cases that would be fine by me too.  ;)
Attachment #631969 - Flags: review?(bzbarsky) → review+
Summary: Consistently use |typename| for type template params in BindingUtil.h → Use typename for type parameters of template template parameters in BindingUtil.h
Attached patch Use typenameSplinter Review
Let's go for minimal churn and only do the change that everybody agrees is an improvement.

Carrying forward r=bz
Attachment #632306 - Flags: review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/f03bb92c3140
Assignee: nobody → bjacob
Target Milestone: --- → mozilla16
https://hg.mozilla.org/mozilla-central/rev/f03bb92c3140
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: