Topic: [c++std-core-27213] [std-proposals] Re:


Author: Andrew Sutton <asutton.list@gmail.com>
Date: Thu, 5 Mar 2015 21:27:37 -0500
Raw View
> The two (what I consider to be very minor) concerns I have:
>
> 1.  Does the definition belong in a header for correctness?

If it declares a function template, then almost certainly.

But as a user who's calling the function, does that matter? The
original comment focused on the information present in the
declaration. From that perspective, I think it matters little how the
function is declared (unless you try to take it's address).

> 2.  Unintended code bloat, since every set of types produces a new
> instantiation.
>
> With the template syntax, you have a very visual way to point that out.
> Both auto and concepts are not visually different than a concrete type.
> (Well your IDE may be able to address this, but syntactically it isn't
> visually different).

That's a reasonable concern, but as you say, very minor. I don't think
I've ever chosen to use a different function because it wasn't a
template, but I can envision reasons for doing so :)

Andrew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-discussion@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-discussion/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 05 Mar 2015 19:09:41 -0800
Raw View
On Thursday 05 March 2015 21:27:37 Andrew Sutton wrote:
> > The two (what I consider to be very minor) concerns I have:
> >
> > 1.  Does the definition belong in a header for correctness?
>
> If it declares a function template, then almost certainly.
>
> But as a user who's calling the function, does that matter? The
> original comment focused on the information present in the
> declaration. From that perspective, I think it matters little how the
> function is declared (unless you try to take it's address).

That's exactly the point.

When you're just using a token, you may not care too much if it is a macro, a
regular function or a template function. You just want it to do the right job.

But if you look up its definition, it should be clear what it is. The argument
is that with a concept type, the fact that it's a template is hidden unless
you look up every single one of the types in the function's declaration.
Finding out whether it's a template function or a macro may important if you
care for #2 below:

> > 2.  Unintended code bloat, since every set of types produces a new
> > instantiation.
> >
> > With the template syntax, you have a very visual way to point that out.
> > Both auto and concepts are not visually different than a concrete type.
> > (Well your IDE may be able to address this, but syntactically it isn't
> > visually different).
>
> That's a reasonable concern, but as you say, very minor. I don't think
> I've ever chosen to use a different function because it wasn't a
> template, but I can envision reasons for doing so :)

I don't think it would be a factor in whether you used it or not. But you may
want to make a note of that for future refactoring of the code, which requires
that you realise that you're doing it.

That said, there are better tools for noticing where the code bloat comes from
than making notes when writing code. We tend to think that the task we're
working on is the single most important thing to have ever happened, when in
the grand scheme of things it might be insignificant.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-discussion@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-discussion/.

.